From aac988327b68b4c1cd6e6eec1b2f92260b81fd34 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 22 Apr 2025 11:04:13 +0200 Subject: [PATCH] out_azure_blob: fixed double free Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index c13da85204d..8d2b8bcea79 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -388,8 +388,12 @@ static int send_blob(struct flb_config *config, } if (!uri) { - flb_free(block_id); + if (block_id != NULL) { + flb_free(block_id); + } + flb_sds_destroy(ref_name); + return FLB_RETRY; } @@ -403,7 +407,11 @@ static int send_blob(struct flb_config *config, &payload_buf, &payload_size); if (ret != 0) { flb_sds_destroy(uri); - flb_free(block_id); + + if (block_id != NULL) { + flb_free(block_id); + } + flb_sds_destroy(ref_name); return FLB_ERROR; } @@ -420,7 +428,6 @@ static int send_blob(struct flb_config *config, /* For Logs type, we need to commit the block right away */ if (event_type == FLB_EVENT_TYPE_LOGS) { ret = azb_block_blob_commit_block(ctx, block_id, tag, ms); - flb_free(block_id); } } else if (ret == CREATE_BLOB) { @@ -436,7 +443,10 @@ static int send_blob(struct flb_config *config, } flb_sds_destroy(uri); - flb_free(block_id); + + if (block_id != NULL) { + flb_free(block_id); + } return ret; } @@ -593,13 +603,13 @@ static int ensure_container(struct flb_azure_blob *ctx) else if (status == 200) { flb_plg_info(ctx->ins, "container '%s' already exists", ctx->container_name); return FLB_TRUE; - } + } else if (status == 403) { flb_plg_error(ctx->ins, "failed getting container '%s', access denied", ctx->container_name); return FLB_FALSE; } - + flb_plg_error(ctx->ins, "get container request failed, status=%i", status);