From 193448ad19ee7634e26b249655146633b7cf5aac Mon Sep 17 00:00:00 2001 From: leonardo-albertovich Date: Sun, 1 Sep 2024 16:12:39 +0200 Subject: [PATCH] bin: fix memory leaks (#9310) Signed-off-by: leonardo-albertovich --- src/fluent-bit.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fluent-bit.c b/src/fluent-bit.c index d35e034ed20..6444b333f2d 100644 --- a/src/fluent-bit.c +++ b/src/fluent-bit.c @@ -809,7 +809,7 @@ static int enable_trace_input(flb_ctx_t *ctx, const char *name, const char *pref static int disable_trace_input(flb_ctx_t *ctx, const char *name) { struct flb_input_instance *in; - + in = find_input(ctx, name); if (in == NULL) { @@ -911,11 +911,18 @@ static int parse_trace_pipeline(flb_ctx_t *ctx, const char *pipeline, char **tra else if (strncmp(key, "output.", strlen("output.")) == 0) { propname = mk_string_copy_substr(key, strlen("output."), strlen(key)); if (propname == NULL) { + mk_mem_free(key); + flb_free(value); + return FLB_ERROR; } propval = flb_strdup(value); if (propval == NULL) { + mk_mem_free(propname); + mk_mem_free(key); + flb_free(value); + return FLB_ERROR; } @@ -927,6 +934,10 @@ static int parse_trace_pipeline(flb_ctx_t *ctx, const char *pipeline, char **tra flb_kv_item_create_len(*props, (char *)propname, strlen(propname), (char *)propval, strlen(propval)); + + mk_mem_free(propname); + flb_free(propval); + } if (key != NULL) {