Skip to content

Commit 7d090b2

Browse files
committed
Avoid undefined behavior caused by malloc(0)
Found by clang-analyzer
1 parent 6616f85 commit 7d090b2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/core/m-pools.c

+2
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
378378

379379
series = (REBSER *)Make_Node(SERIES_POOL);
380380
length *= wide;
381+
ASSERT(length != 0, RP_BAD_SERIES);
382+
381383
pool_num = FIND_POOL(length);
382384
if (pool_num < SYSTEM_POOL) {
383385
pool = &Mem_Pools[pool_num];

0 commit comments

Comments
 (0)