Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions plugins/out_azure_blob/azure_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it possible, that only removing this line should be enough? Calling flb_free on NULL should not be a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removing that line fixes the double free but considering that there are code paths that lead to calling free with block_id holding NULL it's worth adding the check since older systems (and maybe alternative libc implementations?) don't handle it gracefully.

}
}
else if (ret == CREATE_BLOB) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down
Loading