Skip to content

Commit 5c65379

Browse files
committed
config: release kernel context on router creation error
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 781aedf commit 5c65379

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/flb_config.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,33 @@ struct flb_config *flb_config_init()
307307
config->router = flb_router_create(config);
308308
if (!config->router) {
309309
flb_error("[config] could not create router");
310+
if (config->kernel) {
311+
flb_kernel_destroy(config->kernel);
312+
}
313+
#ifdef FLB_HAVE_HTTP_SERVER
314+
if (config->http_listen) {
315+
flb_free(config->http_listen);
316+
}
317+
318+
if (config->http_port) {
319+
flb_free(config->http_port);
320+
}
321+
#endif
322+
flb_cf_destroy(cf);
323+
flb_free(config);
324+
return NULL;
325+
}
326+
ret = flb_routes_mask_set_size(1, config->router);
327+
if (ret != 0) {
328+
flb_error("[config] routing mask dimensioning failed");
329+
flb_router_destroy(config->router);
330+
if (config->kernel) {
331+
flb_kernel_destroy(config->kernel);
332+
}
310333
flb_cf_destroy(cf);
311334
flb_free(config);
312335
return NULL;
313336
}
314-
flb_routes_mask_set_size(1, config->router);
315337

316338
config->cio = NULL;
317339
config->storage_path = NULL;

0 commit comments

Comments
 (0)