diff options
author | Jack Lloyd <[email protected]> | 2017-09-22 21:12:26 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-22 21:12:26 -0400 |
commit | af16c8193a0455e19b6dac47192d90c3077217c6 (patch) | |
tree | 1a37335321714c2aa7dfb13ebb14bcf93bb4db2f /src/lib | |
parent | 6693a5f32d589b66eba7c9a9e144ebd1b70cee57 (diff) |
It's easier to use calloc here
Assumption is calloc checks for overflow (!) so if it returns a
pointer that means no overflow occurred.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/compression/compress_utils.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/lib/compression/compress_utils.cpp b/src/lib/compression/compress_utils.cpp index 6edc22292..f4b41fd5b 100644 --- a/src/lib/compression/compress_utils.cpp +++ b/src/lib/compression/compress_utils.cpp @@ -13,13 +13,8 @@ namespace Botan { void* Compression_Alloc_Info::do_malloc(size_t n, size_t size) { - const size_t total_size = n * size; - - BOTAN_ASSERT_EQUAL(total_size / size, n, "Overflow check"); - // TODO maximum length check here? - - void* ptr = std::malloc(total_size); + void* ptr = std::calloc(n, size); /* * Return null rather than throwing here as we are being called by a @@ -31,8 +26,7 @@ void* Compression_Alloc_Info::do_malloc(size_t n, size_t size) if(ptr) { - std::memset(ptr, 0, total_size); - m_current_allocs[ptr] = total_size; + m_current_allocs[ptr] = n * size; } return ptr; |