Skip to content

Commit 67ad458

Browse files
Leonardo Alminanaedsiper
authored andcommitted
out_azure_blob: fixed double free
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent c52c811 commit 67ad458

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

plugins/out_azure_blob/azure_blob.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,12 @@ static int send_blob(struct flb_config *config,
388388
}
389389

390390
if (!uri) {
391-
flb_free(block_id);
391+
if (block_id != NULL) {
392+
flb_free(block_id);
393+
}
394+
392395
flb_sds_destroy(ref_name);
396+
393397
return FLB_RETRY;
394398
}
395399

@@ -403,7 +407,11 @@ static int send_blob(struct flb_config *config,
403407
&payload_buf, &payload_size);
404408
if (ret != 0) {
405409
flb_sds_destroy(uri);
406-
flb_free(block_id);
410+
411+
if (block_id != NULL) {
412+
flb_free(block_id);
413+
}
414+
407415
flb_sds_destroy(ref_name);
408416
return FLB_ERROR;
409417
}
@@ -420,7 +428,6 @@ static int send_blob(struct flb_config *config,
420428
/* For Logs type, we need to commit the block right away */
421429
if (event_type == FLB_EVENT_TYPE_LOGS) {
422430
ret = azb_block_blob_commit_block(ctx, block_id, tag, ms);
423-
flb_free(block_id);
424431
}
425432
}
426433
else if (ret == CREATE_BLOB) {
@@ -436,7 +443,10 @@ static int send_blob(struct flb_config *config,
436443
}
437444

438445
flb_sds_destroy(uri);
439-
flb_free(block_id);
446+
447+
if (block_id != NULL) {
448+
flb_free(block_id);
449+
}
440450

441451
return ret;
442452
}
@@ -593,13 +603,13 @@ static int ensure_container(struct flb_azure_blob *ctx)
593603
else if (status == 200) {
594604
flb_plg_info(ctx->ins, "container '%s' already exists", ctx->container_name);
595605
return FLB_TRUE;
596-
}
606+
}
597607
else if (status == 403) {
598608
flb_plg_error(ctx->ins, "failed getting container '%s', access denied",
599609
ctx->container_name);
600610
return FLB_FALSE;
601611
}
602-
612+
603613
flb_plg_error(ctx->ins, "get container request failed, status=%i",
604614
status);
605615

0 commit comments

Comments
 (0)