Date: Thu, 20 Aug 1998 17:36:27 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: nate@mt.sri.com (Nate Williams) Cc: imp@village.org, hackers@FreeBSD.ORG Subject: Re: Realloc fix for review Message-ID: <199808210036.RAA11189@bubba.whistle.com> In-Reply-To: <199808201949.NAA08010@mt.sri.com> from Nate Williams at "Aug 20, 98 01:49:38 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Nate Williams 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; > > I just went through the manpage, and it appears that this code is in > fact in-correct. Are you hallucinating, or am I? :-) If realloc() returns a valid pointer, Warner's code does NOT free it. Note "if (!na) free(a)" so realloc() must return NULL for any free'ing to be taking place. This code is correct. Even if any combination of { a, na } are NULL, the code is still valid. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com 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?199808210036.RAA11189>