From 0b59f80625923978583efca08f8e763ea1710bb2 Mon Sep 17 00:00:00 2001 From: Kaz Wesley Date: Wed, 2 Nov 2016 14:11:07 -0700 Subject: [PATCH] LockedPool: fix explosion for illegal-sized alloc Check for unreasonable alloc size in LockedPool rather than lancing through new Arenas until we improbably find one worthy of the quixotic request or the system can support no more Arenas. --- src/support/lockedpool.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 813869a13..be5aac822 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -276,6 +276,11 @@ LockedPool::~LockedPool() void* LockedPool::alloc(size_t size) { std::lock_guard lock(mutex); + + // Don't handle impossible sizes + if (size == 0 || size > ARENA_SIZE) + return nullptr; + // Try allocating from each current arena for (auto &arena: arenas) { void *addr = arena.alloc(size);