about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 685514900c..b6fd367f8b 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3474,7 +3474,7 @@ public_cALLOc(size_t n, size_t elem_size)
 #define HALF_INTERNAL_SIZE_T \
   (((INTERNAL_SIZE_T) 1) << (8 * sizeof (INTERNAL_SIZE_T) / 2))
   if (__builtin_expect ((n | elem_size) >= HALF_INTERNAL_SIZE_T, 0)) {
-    if (bytes / elem_size != n) {
+    if (elem_size != 0 && bytes / elem_size != n) {
       MALLOC_FAILURE_ACTION;
       return 0;
     }