From 5806941692d25a6afbc1d920effa7c8519512156 Mon Sep 17 00:00:00 2001 From: Markus Meyer Date: Sun, 23 Jul 2023 14:01:28 +0200 Subject: [PATCH] Fix issues highlighted by valgrind --- plugins/filter_log_to_metrics/log_to_metrics.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/filter_log_to_metrics/log_to_metrics.c b/plugins/filter_log_to_metrics/log_to_metrics.c index 20f4fcc3b05..5db50a4f33e 100644 --- a/plugins/filter_log_to_metrics/log_to_metrics.c +++ b/plugins/filter_log_to_metrics/log_to_metrics.c @@ -80,6 +80,12 @@ static int log_to_metrics_destroy(struct log_to_metrics_ctx *ctx) delete_rules(ctx); + if (ctx->label_accessors != NULL) { + for (i = 0; i < MAX_LABEL_COUNT; i++) { + flb_free(ctx->label_accessors[i]); + } + flb_free(ctx->label_accessors); + } if (ctx->label_keys != NULL) { for (i = 0; i < MAX_LABEL_COUNT; i++) { flb_free(ctx->label_keys[i]); @@ -273,10 +279,12 @@ static int set_labels(struct log_to_metrics_ctx *ctx, sentry = mk_list_entry_first(split, struct flb_split_entry, _head); tmp = flb_sds_create_len(sentry->value, sentry->len); snprintf(label_keys[counter], MAX_LABEL_LENGTH - 1, "%s", tmp); + flb_sds_destroy(tmp); sentry = mk_list_entry_last(split, struct flb_split_entry, _head); tmp = flb_sds_create_len(sentry->value, sentry->len); snprintf(label_accessors[counter], MAX_LABEL_LENGTH - 1, "%s", tmp); + flb_sds_destroy(tmp); counter++; flb_utils_split_free(split);