Skip to content

Commit 6caa3b8

Browse files
Leonardo Alminanaedsiper
authored andcommitted
decode_prometheus_remote_write: fixed dangling reference and leaks
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent 5c3e1e6 commit 6caa3b8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/cmt_decode_prometheus_remote_write.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ static int decode_histogram_points(struct cmt *cmt,
413413
destroy_label_list(&metric->labels);
414414

415415
free(metric);
416+
417+
return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR;
416418
}
417419
else {
418420
cfl_list_add(&metric->_head, &map->metrics);
@@ -438,7 +440,13 @@ static int decode_histogram_points(struct cmt *cmt,
438440
}
439441
}
440442
else {
441-
free(metric);
443+
if (static_metric_detected == CMT_FALSE) {
444+
destroy_label_list(&metric->labels);
445+
446+
cfl_list_del(&metric->_head);
447+
448+
free(metric);
449+
}
442450

443451
return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR;
444452
}
@@ -452,7 +460,13 @@ static int decode_histogram_points(struct cmt *cmt,
452460
metric->hist_count = hist->count_float;
453461
}
454462
else {
455-
free(metric);
463+
if (static_metric_detected == CMT_FALSE) {
464+
destroy_label_list(&metric->labels);
465+
466+
cfl_list_del(&metric->_head);
467+
468+
free(metric);
469+
}
456470

457471
return CMT_DECODE_PROMETHEUS_REMOTE_WRITE_DECODE_ERROR;
458472
}

0 commit comments

Comments
 (0)