added patch, undo earlier workaround
Jan Dubois [Thu, 11 Jun 1998 20:28:36 +0000 (22:28 +0200)]
Subject: Re: Why does saferealloc(NULL,size) croak? [PATCH] against _66
Message-ID: <35831f69.4975644@smtp1.ibm.net>

p4raw-id: //depot/perl@1125

perl.c
util.c

diff --git a/perl.c b/perl.c
index f436f44..7b76edf 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -604,10 +604,7 @@ CPerlObj::perl_atexit(void (*fn) (CPerlObj*,void *), void *ptr)
 perl_atexit(void (*fn) (void *), void *ptr)
 #endif
 {
-    if(exitlist)
-       Renew(exitlist, exitlistlen+1, PerlExitListEntry);
-    else
-       New(999, exitlist, 1, PerlExitListEntry);
+    Renew(exitlist, exitlistlen+1, PerlExitListEntry);
     exitlist[exitlistlen].fn = fn;
     exitlist[exitlistlen].ptr = ptr;
     ++exitlistlen;
diff --git a/util.c b/util.c
index 7479e47..294a68e 100644 (file)
--- a/util.c
+++ b/util.c
@@ -122,13 +122,18 @@ saferealloc(Malloc_t where,MEM_SIZE size)
        my_exit(1);
     }
 #endif /* HAS_64K_LIMIT */
+    if (!size) {
+       safefree(where);
+       return NULL;
+    }
+
     if (!where)
-       croak("Null realloc");
+       return safemalloc(size);
 #ifdef DEBUGGING
     if ((long)size < 0)
        croak("panic: realloc");
 #endif
-    ptr = PerlMem_realloc(where,size?size:1);  /* realloc(0) is NASTY on our system */
+    ptr = PerlMem_realloc(where,size);
 
 #if !(defined(I286) || defined(atarist))
     DEBUG_m( {