delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/20/18:14:27

Sender: nate AT cartsys DOT com
Message-ID: <37BDD1B6.625F6DE9@cartsys.com>
Date: Fri, 20 Aug 1999 15:07:50 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.12pre4 i586)
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: [RESEND] Re: Possible Bug in realloc()
References: <7pa8ti$73k AT newsstand DOT cit DOT cornell DOT edu>
Reply-To: djgpp-workers AT delorie DOT com

Sorry to resend, but I think this is a fairly important bug and I wanted
to make sure the patch got in.

This fixes a reported bug where a realloc() when memory was exhausted
would dereference NULL and otherwise misbehave.

--- src/libc/ansi/stdlib/malloc.c       Thu Jun  3 14:13:20 1999
+++ src/libc/ansi/stdlib/malloc.c.new   Mon Aug 16 23:58:04 1999
@@ -348,6 +348,8 @@
   }
 
   newptr = (char *)malloc(size);
+  if (!newptr)
+    return NULL;
 #if DEBUG
   printf("realloc %u %u/%08x %08x->%08, %u\n",
         size, b->size & ~1, b, ptr, newptr, copysize);

-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019