Skip to content

Commit

Permalink
decode_prometheus_remote_write: fixed dangling reference and leaks
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 31, 2024
1 parent 5c3e1e6 commit 6caa3b8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/cmt_decode_prometheus_remote_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ static int decode_histogram_points(struct cmt *cmt,
destroy_label_list(&metric->labels);

free(metric);

return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR;
}
else {
cfl_list_add(&metric->_head, &map->metrics);
Expand All @@ -438,7 +440,13 @@ static int decode_histogram_points(struct cmt *cmt,
}
}
else {
free(metric);
if (static_metric_detected == CMT_FALSE) {
destroy_label_list(&metric->labels);

cfl_list_del(&metric->_head);

free(metric);
}

return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR;
}
Expand All @@ -452,7 +460,13 @@ static int decode_histogram_points(struct cmt *cmt,
metric->hist_count = hist->count_float;
}
else {
free(metric);
if (static_metric_detected == CMT_FALSE) {
destroy_label_list(&metric->labels);

cfl_list_del(&metric->_head);

free(metric);
}

return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR;
}
Expand Down

0 comments on commit 6caa3b8

Please sign in to comment.