This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix malloc


Hi!

#include <stdlib.h>

void main (void)
{
  malloc (0x3ffffffc);
}

crashes with new malloc on an i686 box with 256MB of RAM and
no overcommit.
The issue is that if MORECORE_FAILURE != MMAP_FAILED, then
if brk fails and mmap fails too, it would leave brk set to MMAP_FAILED
and so code below would consider it as if brk was successfully set.

2002-03-13  Jakub Jelinek  <jakub@redhat.com>

	* malloc/malloc.c (sYSMALLOc): Set brk to MORECORE_FAILURE if mmap
	failed.

--- libc/malloc/malloc.c.jj	Fri Feb  8 12:04:04 2002
+++ libc/malloc/malloc.c	Wed Mar 13 12:44:48 2002
@@ -2838,7 +2838,8 @@ static Void_t* sYSMALLOc(nb, av) INTERNA
            bridge regions.
         */
         set_noncontiguous(av);
-      }
+      } else
+	brk = (char *)(MORECORE_FAILURE);
     }
 #endif
   }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]