Skip to content

Commit

Permalink
Fix issues highlighted by valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
wndhydrnt committed Jul 23, 2023
1 parent fa27de1 commit 5806941
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/filter_log_to_metrics/log_to_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5806941

Please sign in to comment.