aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-08-01 19:02:37 -0400
committerJack Lloyd <[email protected]>2019-08-01 19:02:37 -0400
commit402b727b251b5f451ffb790fa29db84e5e6a06fb (patch)
tree5afbb525b4874267be3e1d97a9fe65ee9e917a85 /src/lib/utils
parentefe2ef18eccbce25002518776ae0269c62cd3676 (diff)
Return nullptr for size 0 allocation
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/mem_ops.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/utils/mem_ops.cpp b/src/lib/utils/mem_ops.cpp
index 460fc4b69..9ef1d6c4e 100644
--- a/src/lib/utils/mem_ops.cpp
+++ b/src/lib/utils/mem_ops.cpp
@@ -17,6 +17,9 @@ namespace Botan {
BOTAN_MALLOC_FN void* allocate_memory(size_t elems, size_t elem_size)
{
+ if(elems == 0 || elem_size == 0)
+ return nullptr;
+
#if defined(BOTAN_HAS_LOCKING_ALLOCATOR)
if(void* p = mlock_allocator::instance().allocate(elems, elem_size))
return p;