From 6d9d9bee580c93a4b80951d9d8a804becd4bcbcb Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Fri, 3 Nov 2023 12:41:02 -0300 Subject: [PATCH] in_calyptia_fleet: free up filenames and data during collect callback. Signed-off-by: Phillip Whelan --- plugins/in_calyptia_fleet/in_calyptia_fleet.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index d81628e5772..b2f48ea6e1a 100644 --- a/plugins/in_calyptia_fleet/in_calyptia_fleet.c +++ b/plugins/in_calyptia_fleet/in_calyptia_fleet.c @@ -851,6 +851,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins, if (cfgfp == NULL) { flb_plg_error(ctx->ins, "unable to open configuration file: %s", cfgname); + flb_sds_destroy(cfgname); goto payload_error; } @@ -900,12 +901,14 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins, } if (hdr == NULL) { fclose(cfgfp); + flb_sds_destroy(cfgname); goto header_error; } if (ctx->machine_id) { hdr = flb_sds_printf(&header, " machine_id %s\n", ctx->machine_id); if (hdr == NULL) { fclose(cfgfp); + flb_sds_destroy(cfgname); goto header_error; } } @@ -934,13 +937,13 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins, flb_errno(); #endif } + + flb_sds_destroy(cfgnewname); } if (ctx->config_timestamp < time_last_modified) { flb_plg_debug(ctx->ins, "new configuration is newer than current: %ld < %ld", ctx->config_timestamp, time_last_modified); - flb_sds_destroy(data); - data = NULL; if (execute_reload(ctx, cfgname) == FLB_FALSE) { cfgoldname = old_fleet_config_filename(ctx); @@ -948,9 +951,13 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins, rename(cfgoldname, cfgcurname); flb_sds_destroy(cfgcurname); flb_sds_destroy(cfgoldname); + flb_sds_destroy(cfgname); goto reload_error; } } + else { + flb_sds_destroy(cfgname); + } ret = 0; @@ -965,6 +972,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins, } http_error: + flb_plg_debug(ctx->ins, "freeing http client in fleet collect"); flb_http_client_destroy(client); client_error: flb_upstream_conn_release(u_conn);