Skip to content

Commit 39e1b3b

Browse files
kazcwfurszy
authored andcommitted
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 adb1f1c commit 39e1b3b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/support/lockedpool.cpp

+5
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)