From owner-freebsd-bugs@FreeBSD.ORG Tue Mar 2 14:30:14 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB0D616A4D1 for ; Tue, 2 Mar 2004 14:30:14 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B590E43D1D for ; Tue, 2 Mar 2004 14:30:14 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i22MUEbv041842 for ; Tue, 2 Mar 2004 14:30:14 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i22MUEVZ041841; Tue, 2 Mar 2004 14:30:14 -0800 (PST) (envelope-from gnats) Date: Tue, 2 Mar 2004 14:30:14 -0800 (PST) Message-Id: <200403022230.i22MUEVZ041841@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Stefan Farfeleder Subject: Re: bin/62859: [patch] malloc(0) fails to call malloc_init() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Stefan Farfeleder List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2004 22:30:14 -0000 The following reply was made to PR bin/62859; it has been noted by GNATS. From: Stefan Farfeleder To: bug-followup@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--