Fix issue detected by new test.
This commit is contained in:
1 parent
7ffe20bea7
commit
e8ae66371a
1 file changed
+12
-6
+12
-6
@@ -199,13 +199,19 @@ bitset_reserve (bitset_t v, size_t size)
|
|||||||
if (oldAlloc > newAlloc) {
|
if (oldAlloc > newAlloc) {
|
||||||
newAlloc = oldAlloc;
|
newAlloc = oldAlloc;
|
||||||
}
|
}
|
||||||
bitset_limb *ptr = M_MEMORY_REALLOC (bitset_limb, v->ptr, newAlloc);
|
if (M_UNLIKELY (newAlloc == 0)) {
|
||||||
if (M_UNLIKELY (ptr == NULL) ) {
|
M_MEMORY_FREE (v->ptr);
|
||||||
M_MEMORY_FULL(newAlloc * sizeof(bitset_limb));
|
v->size = v->alloc = 0;
|
||||||
return;
|
v->ptr = NULL;
|
||||||
|
} else {
|
||||||
|
bitset_limb *ptr = M_MEMORY_REALLOC (bitset_limb, v->ptr, newAlloc);
|
||||||
|
if (M_UNLIKELY (ptr == NULL) ) {
|
||||||
|
M_MEMORY_FULL(newAlloc * sizeof(bitset_limb));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
v->ptr = ptr;
|
||||||
|
v->alloc = newAlloc;
|
||||||
}
|
}
|
||||||
v->ptr = ptr;
|
|
||||||
v->alloc = newAlloc;
|
|
||||||
BITSETI_CONTRACT (v);
|
BITSETI_CONTRACT (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user