Skip to content

Commit 9594a76

Browse files
DavidKorczynskimikeb01
authored andcommitted
hdr_historgram_log: fix 3 memory leaks on histogram-counts
The fuzzer from #120 found some leaks when the `hdr_decode_compressed*` functions call `hdr_init` but later fails and cleans up `h` by way of `hdr_free(h)`. The problem is that the `counts` field on the histogram is leaked, which is allocated https://github.com/HdrHistogram/HdrHistogram_c/blob/8dcce8f68512fca460b171bccc3a5afce0048779/src/hdr_histogram.c#L424 and assigned to the `counts` field here: https://github.com/HdrHistogram/HdrHistogram_c/blob/8dcce8f68512fca460b171bccc3a5afce0048779/src/hdr_histogram.c#L437 Signed-off-by: David Korczynski <[email protected]>
1 parent 133e074 commit 9594a76

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/hdr_histogram_log.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static int hdr_decode_compressed_v0(
442442

443443
if (result != 0)
444444
{
445-
hdr_free(h);
445+
hdr_close(h);
446446
}
447447
else if (NULL == *histogram)
448448
{
@@ -547,7 +547,7 @@ static int hdr_decode_compressed_v1(
547547

548548
if (result != 0)
549549
{
550-
hdr_free(h);
550+
hdr_close(h);
551551
}
552552
else if (NULL == *histogram)
553553
{
@@ -649,7 +649,7 @@ static int hdr_decode_compressed_v2(
649649

650650
if (result != 0)
651651
{
652-
hdr_free(h);
652+
hdr_close(h);
653653
}
654654
else if (NULL == *histogram)
655655
{

0 commit comments

Comments
 (0)