Skip to content

Commit

Permalink
log: fix memory leaks in the error case
Browse files Browse the repository at this point in the history
  • Loading branch information
takahasi committed Feb 15, 2017
1 parent 6bc51f2 commit b832e80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/flb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ flb_ctx_t *flb_create()
int ret;
flb_ctx_t *ctx;
struct flb_config *config;
struct flb_log *log;

#ifdef FLB_HAVE_MTRACE
/* Start tracing malloc and free */
Expand All @@ -115,7 +116,11 @@ flb_ctx_t *flb_create()
ctx->config = config;

/* Initialize logger */
flb_log_init(config, FLB_LOG_STDERR, FLB_LOG_INFO, NULL);
log = flb_log_init(config, FLB_LOG_STDERR, FLB_LOG_INFO, NULL);
if (!log) {
flb_free(ctx);
return NULL;
}

/* Initialize our pipe to send data to our worker */
ret = flb_pipe_create(config->ch_data);
Expand Down
1 change: 1 addition & 0 deletions src/flb_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ struct flb_log *flb_log_init(struct flb_config *config, int type,
if (ret == -1) {
pthread_mutex_unlock(&pth_mutex);
mk_event_loop_destroy(log->evl);
flb_free(log->worker);
flb_free(log);
return NULL;
}
Expand Down

0 comments on commit b832e80

Please sign in to comment.