From 5cade1bfa3d2c4e2ccf4abeecd477889faaf12dd Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Wed, 25 Sep 2024 17:29:59 +0900 Subject: [PATCH] encode_opentelemetry: Plug memory leaks on cutoff Signed-off-by: Hiroshi Hatake --- src/cmt_encode_opentelemetry.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmt_encode_opentelemetry.c b/src/cmt_encode_opentelemetry.c index 5af3465..7542f0f 100644 --- a/src/cmt_encode_opentelemetry.c +++ b/src/cmt_encode_opentelemetry.c @@ -2449,6 +2449,8 @@ int pack_basic_type(struct cmt_opentelemetry_context *context, if (check_staled_timestamp(&map->metric, now, CMT_ENCODE_OPENTELEMETRY_CUTOFF_THRESHOLD)) { + destroy_metric(metric); + /* Skip processing metrics which are staled over the threshold */ return CMT_ENCODE_OPENTELEMETRY_CUTOFF_ERROR; } @@ -2465,6 +2467,8 @@ int pack_basic_type(struct cmt_opentelemetry_context *context, if (check_staled_timestamp(&map->metric, now, CMT_ENCODE_OPENTELEMETRY_CUTOFF_THRESHOLD)) { + destroy_metric(metric); + /* Skip processing metrics which are staled over the threshold */ return CMT_ENCODE_OPENTELEMETRY_CUTOFF_ERROR; }