From 4dc3385bc0b0f45e793aace371f9b348c62e388c Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 9 Dec 2018 10:58:34 -0500 Subject: [PATCH] fix calloc for nmemb == 0 and !ZERO_ON_FREE --- h_malloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h_malloc.c b/h_malloc.c index 7d659af..5ea336f 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -1087,7 +1087,7 @@ EXPORT void *h_calloc(size_t nmemb, size_t size) { total_size = adjust_size_for_canaries(total_size); void *p = allocate(total_size); thread_seal_metadata(); - if (!ZERO_ON_FREE && likely(p != NULL) && size && size <= max_slab_size_class) { + if (!ZERO_ON_FREE && likely(p != NULL) && total_size && total_size <= max_slab_size_class) { memset(p, 0, total_size - canary_size); } return p;