From 4e96517bb25b30ea3ccb1ece0fe04c2d0c60e59a Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Tue, 26 Sep 2017 22:42:09 +0200 Subject: [PATCH] Add init to 0 to unitialized memory as raised by scan-build. --- m-bitset.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/m-bitset.h b/m-bitset.h index 2ce315e9..e3624a91 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -182,6 +182,9 @@ bitset_push_back (bitset_t v, bool x) M_MEMORY_FULL(needAlloc * sizeof(bitset_limb)); return; } + // Clear allocated memory + for(size_t a = v->alloc; a < needAlloc; a++) + ptr[a] = 0; v->ptr = ptr; v->alloc = needAlloc; } @@ -360,6 +363,8 @@ bitset_push_at(bitset_t set, size_t key, bool value) size_t size = (set->size + BITSET_LIMB_BIT - 1) / BITSET_LIMB_BIT; assert (size >= offset + 1); v = bitseti_lshift(&set->ptr[offset+1], size - offset - 1, carry); + // v is unused. + (void) v; BITSETI_CONTRACT (set); }