Fix overflow issue.

This commit is contained in:
Patrick Pelissier committed 2017-08-06 23:05:21 +02:00
1 parent 14c50a5b9a
commit a4946a39bc
1 file changed
+4
+4
View File
@@ -154,6 +154,10 @@ bitset_push_back (bitset_t v, bool x)
BITSETI_CONTRACT (v);
if (v->size >= BITSETI_FROM_ALLOC (v->alloc)) {
const size_t needAlloc = BITSETI_INC_ALLOC_SIZE(v->alloc);
if (M_UNLIKELY (needAlloc <= v->alloc)) {
M_MEMORY_FULL(needAlloc * sizeof(bitset_limb));
return;
}
bitset_limb *ptr = M_MEMORY_REALLOC (bitset_limb, v->ptr, needAlloc);
if (M_UNLIKELY (ptr == NULL) ) {
M_MEMORY_FULL(needAlloc * sizeof(bitset_limb));