about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index c54c203cbf..fc8a83c328 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3886,6 +3886,12 @@ public_cALLOc(size_t n, size_t elem_size)
       oldtopsize < mp_.sbrk_base + av->max_system_mem - (char *)oldtop)
     oldtopsize = (mp_.sbrk_base + av->max_system_mem - (char *)oldtop);
 #endif
+  if (av != &main_arena)
+    {
+      heap_info *heap = heap_for_ptr (oldtop);
+      if (oldtopsize < (char *) heap + heap->mprotect_size - (char *) oldtop)
+	oldtopsize = (char *) heap + heap->mprotect_size - (char *) oldtop;
+    }
 #endif
   mem = _int_malloc(av, sz);