Skip to content

Commit 3b7dbbb

Browse files
committed
out_opentelemetry: fix leaks on exceptions
Signed-off-by: Eduardo Silva <[email protected]>
1 parent d09686c commit 3b7dbbb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

plugins/out_opentelemetry/opentelemetry_conf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ static int check_proxy(struct flb_output_instance *ins,
199199
return -1;
200200
}
201201

202+
if (ctx->proxy_host) {
203+
flb_free(ctx->proxy_host);
204+
}
202205
ctx->proxy_host = host;
203206
ctx->proxy_port = atoi(port);
204207
ctx->proxy = tmp;
@@ -274,6 +277,7 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output
274277
/* Parse 'add_label' */
275278
ret = config_add_labels(ins, ctx);
276279
if (ret == -1) {
280+
flb_opentelemetry_context_destroy(ctx);
277281
return NULL;
278282
}
279283

plugins/out_opentelemetry/opentelemetry_logs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ int otel_process_logs(struct flb_event_chunk *event_chunk,
11721172
if (ret == -1) {
11731173
/* the only possible fail path is a problem with a memory allocation, let's suggest a FLB_RETRY */
11741174
ret = FLB_RETRY;
1175+
flb_free(log_record);
1176+
log_records[log_record_count] = NULL;
11751177
break;
11761178
}
11771179

@@ -1180,6 +1182,11 @@ int otel_process_logs(struct flb_event_chunk *event_chunk,
11801182
if (ret == -1) {
11811183
/* as before, it can only fail on a memory allocation */
11821184
ret = FLB_RETRY;
1185+
if (log_record->body) {
1186+
otlp_any_value_destroy(log_record->body);
1187+
}
1188+
flb_free(log_record);
1189+
log_records[log_record_count] = NULL;
11831190
break;
11841191
}
11851192

0 commit comments

Comments
 (0)