diff --git a/src/flb_lib.c b/src/flb_lib.c index 2b67f0368df..f054190a146 100644 --- a/src/flb_lib.c +++ b/src/flb_lib.c @@ -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 */ @@ -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); diff --git a/src/flb_log.c b/src/flb_log.c index 4260e2ab951..f7e71ade04b 100644 --- a/src/flb_log.c +++ b/src/flb_log.c @@ -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; }