Skip to content

Commit

Permalink
out_stackdriver: fixed a memory leak
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich authored and edsiper committed Aug 29, 2024
1 parent a24c72c commit 66a9cd1
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions plugins/out_stackdriver/stackdriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2304,9 +2304,22 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx,
insert_id_extracted = FLB_FALSE;
}
else {
if (trace_extracted == FLB_TRUE) {
flb_sds_destroy(trace);
}

if (span_id_extracted == FLB_TRUE) {
flb_sds_destroy(span_id);
}

if (project_id_extracted == FLB_TRUE) {
flb_sds_destroy(project_id_key);
}

if (log_name_extracted == FLB_TRUE) {
flb_sds_destroy(log_name);
}

continue;
}

Expand Down Expand Up @@ -2357,10 +2370,26 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx,
flb_plg_error(ctx->ins, "the type of payload labels should be map");
flb_sds_destroy(operation_id);
flb_sds_destroy(operation_producer);
flb_sds_destroy(trace);
flb_sds_destroy(log_name);

if (trace_extracted == FLB_TRUE) {
flb_sds_destroy(trace);
}

if (span_id_extracted == FLB_TRUE) {
flb_sds_destroy(span_id);
}

if (project_id_extracted == FLB_TRUE) {
flb_sds_destroy(project_id_key);
}

if (log_name_extracted == FLB_TRUE) {
flb_sds_destroy(log_name);
}

flb_log_event_decoder_destroy(&log_decoder);
msgpack_sbuffer_destroy(&mp_sbuf);

return NULL;
}

Expand Down

0 comments on commit 66a9cd1

Please sign in to comment.