diff options
author | Kaz Wesley <keziahw@gmail.com> | 2016-11-02 14:11:07 -0700 |
---|---|---|
committer | Kaz Wesley <keziahw@gmail.com> | 2016-11-02 14:41:40 -0700 |
commit | 0b59f80625923978583efca08f8e763ea1710bb2 (patch) | |
tree | 47f951130b8fc915117a246a97a47697f506f8df /src | |
parent | 21b8f3db31f05f7756c4291e460544ce0457fd87 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/support/lockedpool.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 813869a131..be5aac8227 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<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); |