From a3d5e6ce735156ac384187cd1d98f5e8eed52760 Mon Sep 17 00:00:00 2001 From: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:58:08 +0200 Subject: [PATCH] Free key and search, replace patterns (#16789) Free key and search pattern --- collectors/log2journal/log2journal-yaml.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collectors/log2journal/log2journal-yaml.c b/collectors/log2journal/log2journal-yaml.c index 2a0da81df8888a..3ca0576d143556 100644 --- a/collectors/log2journal/log2journal-yaml.c +++ b/collectors/log2journal/log2journal-yaml.c @@ -464,6 +464,7 @@ static size_t yaml_parse_rewrites(yaml_parser_t *parser, LOG_JOB *jb) { yaml_error(parser, &sub_event, "Expected scalar for rewrite key"); errors++; } else { + freez(key); key = strndupz((char *)sub_event.data.scalar.value, sub_event.data.scalar.length); yaml_event_delete(&sub_event); } @@ -498,6 +499,7 @@ static size_t yaml_parse_rewrites(yaml_parser_t *parser, LOG_JOB *jb) { yaml_error(parser, &sub_event, "Expected scalar for rewrite value"); errors++; } else { + freez(replace_pattern); replace_pattern = strndupz((char *)sub_event.data.scalar.value, sub_event.data.scalar.length); yaml_event_delete(&sub_event); } @@ -563,6 +565,8 @@ static size_t yaml_parse_rewrites(yaml_parser_t *parser, LOG_JOB *jb) { } freez(replace_pattern); replace_pattern = NULL; + freez(search_pattern); + search_pattern = NULL; } break;