mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-17 18:40:09 +00:00
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:
parent
21b8f3db31
commit
0b59f80625
@ -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…
x
Reference in New Issue
Block a user