diff options
author | Jack Lloyd <[email protected]> | 2019-08-01 19:02:37 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-08-01 19:02:37 -0400 |
commit | 402b727b251b5f451ffb790fa29db84e5e6a06fb (patch) | |
tree | 5afbb525b4874267be3e1d97a9fe65ee9e917a85 | |
parent | efe2ef18eccbce25002518776ae0269c62cd3676 (diff) |
Return nullptr for size 0 allocation
-rw-r--r-- | src/lib/utils/mem_ops.cpp | 3 |
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; |