Skip to content

Commit 0b59f80

Browse files
committed
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.
1 parent 21b8f3d commit 0b59f80

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/support/lockedpool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ LockedPool::~LockedPool()
276276
void* LockedPool::alloc(size_t size)
277277
{
278278
std::lock_guard<std::mutex> lock(mutex);
279+
280+
// Don't handle impossible sizes
281+
if (size == 0 || size > ARENA_SIZE)
282+
return nullptr;
283+
279284
// Try allocating from each current arena
280285
for (auto &arena: arenas) {
281286
void *addr = arena.alloc(size);

0 commit comments

Comments
 (0)