AT&T Unix PC : 15-realloc-null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On UnixPC, realloc of a NULL pointer returns NULL, whereas on most
today's architectures it behaves the same way as malloc.

So we just wrap it.

Regards,

Alain

diff -X ../exclude.txt -urN dash-0.5.12+14-broken-wait-h/src/memalloc.c dash-0.5.12+15-realloc-null/src/memalloc.c
--- dash-0.5.12+14-broken-wait-h/src/memalloc.c	2024-10-27 20:32:54.604833876 +0000
+++ dash-0.5.12+15-realloc-null/src/memalloc.c	2024-10-27 20:32:44.700597405 +0000
@@ -68,7 +68,10 @@
 pointer
 ckrealloc(pointer p, size_t nbytes)
 {
-	p = realloc(p, nbytes);
+	if(p == NULL)
+		p = malloc(nbytes);
+	else
+		p = realloc(p, nbytes);
 	if (p == NULL)
 		sh_error("Out of space");
 	return p;




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux