From 611f94fc69638c5ceab2093936a98d3a5cee4140 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, 11 insertions(+), 1 deletion(-) diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index 45d047b708e..cd99b1e023f 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 http_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 http_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 http_error; } } @@ -933,12 +936,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); if (execute_reload(ctx, cfgname) == FLB_FALSE) { cfgoldname = old_fleet_config_filename(ctx); @@ -946,14 +950,20 @@ 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; reload_error: + flb_sds_destroy(data); 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);