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]

Re: [PATCH] Fix malloc


Hi,

> 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.

Clearly you're right.  I'd rather not change 'brk' at all though,
like below:

2002-03-13  Wolfram Gloger  <wg@malloc.de>

	* malloc/malloc.c (sYSMALLOc): Don't change brk if mmap
	failed.

--- malloc.c	2002/02/15 09:30:28	1.6
+++ malloc.c	2002/03/13 12:06:55
@@ -2824,11 +2824,12 @@
     /* Don't try if size wraps around 0 */
     if ((unsigned long)(size) > (unsigned long)(nb)) {
 
-      brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
+      char *mbrk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
 
-      if (brk != MAP_FAILED) {
+      if (mbrk != MAP_FAILED) {
 
         /* We do not need, and cannot use, another sbrk call to find end */
+        brk = mbrk;
         snd_brk = brk + size;
 
         /*


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