diff options
| author | Kaz Wesley <[email protected]> | 2016-11-02 14:11:07 -0700 |
|---|---|---|
| committer | Kaz Wesley <[email protected]> | 2016-11-02 14:41:40 -0700 |
| commit | 0b59f80625923978583efca08f8e763ea1710bb2 (patch) | |
| tree | 47f951130b8fc915117a246a97a47697f506f8df /src/support/lockedpool.cpp | |
| parent | LockedPool: test handling of invalid allocations (diff) | |
| download | discoin-0b59f80625923978583efca08f8e763ea1710bb2.tar.xz discoin-0b59f80625923978583efca08f8e763ea1710bb2.zip | |
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/support/lockedpool.cpp')
| -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 813869a13..be5aac822 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); |