From a4946a39bc56a66e071201cadca72f422941561f Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 6 Aug 2017 23:05:21 +0200 Subject: [PATCH] Fix overflow issue. --- m-bitset.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/m-bitset.h b/m-bitset.h index 28a33777..ee7e4e56 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -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));