bin/62859: [patch] malloc(0) fails to call malloc_init()
Stefan Farfeleder
stefan at fafoe.narf.at
Tue Mar 2 14:30:14 PST 2004
The following reply was made to PR bin/62859; it has been noted by GNATS.
From: Stefan Farfeleder <stefan at fafoe.narf.at>
To: bug-followup at freebsd.org
Cc:
Subject: Re: bin/62859: [patch] malloc(0) fails to call malloc_init()
Date: Tue, 2 Mar 2004 23:27:16 +0100
--GPJrCs/72TxItFYR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
The patch in the PR is OBE, here's a new one.
Stefan
--GPJrCs/72TxItFYR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="malloc.c.diff"
Index: src/lib/libc/stdlib/malloc.c
===================================================================
RCS file: /usr/home/ncvs/src/lib/libc/stdlib/malloc.c,v
retrieving revision 1.86
diff -I.svn -u -r1.86 malloc.c
--- src/lib/libc/stdlib/malloc.c 21 Feb 2004 09:14:38 -0000 1.86
+++ src/lib/libc/stdlib/malloc.c 23 Feb 2004 13:39:59 -0000
@@ -729,9 +729,6 @@
{
void *result;
- if (!malloc_started)
- malloc_init();
-
if (suicide)
abort();
@@ -764,11 +761,6 @@
if (suicide)
abort();
- if (!malloc_started) {
- wrtwarning("malloc() has never been called\n");
- return (NULL);
- }
-
index = ptr2index(ptr);
if (index < malloc_pageshift) {
@@ -1061,11 +1053,6 @@
if (ptr == NULL)
return;
- if (!malloc_started) {
- wrtwarning("malloc() has never been called\n");
- return;
- }
-
/* If we're already sinking, don't make matters any worse. */
if (suicide)
return;
@@ -1118,6 +1105,13 @@
if (ptr == ZEROSIZEPTR)
ptr = NULL;
+ if (!malloc_started) {
+ malloc_init();
+ if (ptr != NULL) {
+ wrtwarning("malloc() has never been called\n");
+ return (NULL);
+ }
+ }
if (malloc_sysv && !size) {
if (ptr != NULL)
ifree(ptr);
--GPJrCs/72TxItFYR--
More information about the freebsd-bugs
mailing list