From 9d0c2e35af1a2c7d392b995851ec83ca73ffa0cd Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Tue, 3 Sep 2024 12:26:31 +0200 Subject: [PATCH] encode_opentelemetry: fixed memory leaks Signed-off-by: Leonardo Alminana --- src/ctr_encode_opentelemetry.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ctr_encode_opentelemetry.c b/src/ctr_encode_opentelemetry.c index 8f0c81e..c1e9c24 100644 --- a/src/ctr_encode_opentelemetry.c +++ b/src/ctr_encode_opentelemetry.c @@ -976,6 +976,12 @@ static Opentelemetry__Proto__Trace__V1__ScopeSpans **set_scope_spans(struct ctra otel_scope_span = initialize_scope_span(); if (!otel_scope_span) { + if (scope_span_index > 0) { + destroy_scope_spans(scope_spans, scope_span_index - 1); + } + + free(scope_spans); + return NULL; }