Fix buffer overflow if size=64*N

This commit is contained in:
Patrick Pelissier committed 2021-03-13 23:39:26 +01:00
1 parent 7d262f2450
commit 0edb6165b5
1 file changed
+2 -3
+2 -3
View File
@@ -269,13 +269,12 @@ bitset_resize (bitset_t v, size_t size)
} else if (size > old_size) {
// Resize up the bitset: set to 0 new bits.
const size_t old_offset = old_size / M_B1TSET_LIMB_BIT;
for(size_t i = old_offset+1 ; i <= offset; i++) {
for(size_t i = old_offset+1 ; i < offset; i++) {
v->ptr[i] = 0;
}
if (M_LIKELY(index != 0)) {
// Mask the last limb to clear the last bits
// Needed only if old_offset == offset
v->ptr[offset] &= mask;
v->ptr[offset] = 0;
}
}
v->size = size;