From 2d5669770a5723d258703384f905e1d13d6b8696 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 23 Mar 2015 02:15:45 +0000 Subject: Avoid putting very small values in mlock memory --- src/lib/alloc/locking_allocator/locking_allocator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/lib/alloc/locking_allocator') diff --git a/src/lib/alloc/locking_allocator/locking_allocator.cpp b/src/lib/alloc/locking_allocator/locking_allocator.cpp index 4a3dd3c4c..48aec5ce4 100644 --- a/src/lib/alloc/locking_allocator/locking_allocator.cpp +++ b/src/lib/alloc/locking_allocator/locking_allocator.cpp @@ -103,7 +103,9 @@ void* mlock_allocator::allocate(size_t num_elems, size_t elem_size) if(n / elem_size != num_elems) return nullptr; // overflow! - if(n > m_poolsize || n > BOTAN_MLOCK_ALLOCATOR_MAX_ALLOCATION) + if(n > m_poolsize) + return nullptr; + if(n < BOTAN_MLOCK_ALLOCATOR_MIN_ALLOCATION || n > BOTAN_MLOCK_ALLOCATOR_MAX_ALLOCATION) return nullptr; std::lock_guard lock(m_mutex); -- cgit v1.2.3