From 3c0fd15b1e04281b2ada00cf82ddffc4b3292dee Mon Sep 17 00:00:00 2001 From: Garand Tyson Date: Fri, 12 Jul 2024 12:22:33 -0700 Subject: [PATCH] Fixed unitialized Fingerprints bug (#56) --- include/binaryfusefilter.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/binaryfusefilter.h b/include/binaryfusefilter.h index 9bdc590..c076c77 100644 --- a/include/binaryfusefilter.h +++ b/include/binaryfusefilter.h @@ -243,7 +243,8 @@ static inline bool binary_fuse8_allocate(uint32_t size, filter->ArrayLength = (filter->SegmentCount + arity - 1) * filter->SegmentLength; filter->SegmentCountLength = filter->SegmentCount * filter->SegmentLength; - filter->Fingerprints = (uint8_t*)malloc(filter->ArrayLength); + filter->Fingerprints = + (uint8_t *)calloc(filter->ArrayLength, sizeof(uint8_t)); return filter->Fingerprints != NULL; } @@ -530,7 +531,8 @@ static inline bool binary_fuse16_allocate(uint32_t size, filter->ArrayLength = (filter->SegmentCount + arity - 1) * filter->SegmentLength; filter->SegmentCountLength = filter->SegmentCount * filter->SegmentLength; - filter->Fingerprints = (uint16_t*)malloc(filter->ArrayLength * sizeof(uint16_t)); + filter->Fingerprints = + (uint16_t *)calloc(filter->ArrayLength, sizeof(uint16_t)); return filter->Fingerprints != NULL; }