about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 68d8752de6..ce8de8015b 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2938,9 +2938,12 @@ chunk_alloc(ar_ptr, nb) arena *ar_ptr; INTERNAL_SIZE_T nb;
     if ((remainder_size = chunksize(top(ar_ptr)) - nb) < (long)MINSIZE)
     {
 #if HAVE_MMAP
-      /* A last attempt:  when we are out of address space in the arena,
-         try mmap anyway, as long as it is allowed at all.  */
-      if (n_mmaps_max > 0 && (victim = mmap_chunk(nb)) != 0)
+      /* A last attempt: when we are out of address space in a
+         non-main arena, try mmap anyway, as long as it is allowed at
+         all.  */
+      if (ar_ptr != &main_arena &&
+          n_mmaps_max > 0 &&
+          (victim = mmap_chunk(nb)) != 0)
         return victim;
 #endif
       return 0; /* propagate failure */