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.
This commit is contained in:
Kaz Wesley 2016-11-02 14:11:07 -07:00
parent 21b8f3db31
commit 0b59f80625
1 changed files with 5 additions and 0 deletions

View File

@ -276,6 +276,11 @@ LockedPool::~LockedPool()
void* LockedPool::alloc(size_t size)
{
std::lock_guard<std::mutex> 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);