Skip to content

Commit

Permalink
hdr_historgram_log: fix 3 memory leaks on histogram-counts
Browse files Browse the repository at this point in the history
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 <david@adalogics.com>
  • Loading branch information
DavidKorczynski authored and mikeb01 committed Jan 15, 2024
1 parent 133e074 commit 9594a76
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hdr_histogram_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static int hdr_decode_compressed_v0(

if (result != 0)
{
hdr_free(h);
hdr_close(h);
}
else if (NULL == *histogram)
{
Expand Down Expand Up @@ -547,7 +547,7 @@ static int hdr_decode_compressed_v1(

if (result != 0)
{
hdr_free(h);
hdr_close(h);
}
else if (NULL == *histogram)
{
Expand Down Expand Up @@ -649,7 +649,7 @@ static int hdr_decode_compressed_v2(

if (result != 0)
{
hdr_free(h);
hdr_close(h);
}
else if (NULL == *histogram)
{
Expand Down

0 comments on commit 9594a76

Please sign in to comment.