Browse Source

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.
0.14
Kaz Wesley 8 years ago
parent
commit
0b59f80625
  1. 5
      src/support/lockedpool.cpp

5
src/support/lockedpool.cpp

@ -276,6 +276,11 @@ LockedPool::~LockedPool()
void* LockedPool::alloc(size_t size) void* LockedPool::alloc(size_t size)
{ {
std::lock_guard<std::mutex> lock(mutex); 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 // Try allocating from each current arena
for (auto &arena: arenas) { for (auto &arena: arenas) {
void *addr = arena.alloc(size); void *addr = arena.alloc(size);

Loading…
Cancel
Save