Date: 20 Aug 1998 16:48:46 +0000 From: dag-erli@ifi.uio.no (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?= ) To: Warner Losh <imp@village.org> Cc: hackers@FreeBSD.ORG Subject: Re: Realloc fix for review Message-ID: <xzplnoj8uq9.fsf@skejdbrimir.ifi.uio.no> In-Reply-To: Warner Losh's message of "Thu, 20 Aug 1998 10:19:42 -0600" References: <199808201619.KAA20970@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Warner Losh <imp@village.org> writes: > Recently, OpenBSD went through their source tree and fixed all > instances of > a = realloc(a, size); > with > na = realloc(a, size); > if (!na) > free(a); > a = na; Is that really a good idea? If you free the old block when realloc() fails, you lose whatever data was in it (and therefore potentially lose the ability to generate a sensible error message or recover gracefully). Such a change should be done on a per-case basis, rather than blindly applied to every snippet that calls realloc(). DES -- Dag-Erling Smørgrav - dag-erli@ifi.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzplnoj8uq9.fsf>