Date: Thu, 20 Aug 1998 16:21:51 -0600 From: Warner Losh <imp@village.org> To: Archie Cobbs <archie@whistle.com> Cc: eivind@yes.no (Eivind Eklund), hackers@FreeBSD.ORG Subject: Re: Realloc fix for review Message-ID: <199808202221.QAA25040@harmony.village.org> In-Reply-To: Your message of "Thu, 20 Aug 1998 14:55:39 PDT." <199808202155.OAA09132@bubba.whistle.com> References: <199808202155.OAA09132@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <199808202155.OAA09132@bubba.whistle.com> Archie Cobbs writes: : A better thing would be to replace all instances of "a = realloc(a, size)" : with <insert bug-free code here>, depending on what the program is trying : to do in that particular instance. If you actually look at the code, you'll find that most of the code that does this realloc, does check to see if a is NULL. The only bug in most of the code that I've seen is that it doesn't free a in the failure case. That's why I invented frealloc. That is, the code generally deals with failre nearly correctly. for example, in getcap we have: record = realloc(record, newsize); if (record == NULL) { errno = ENOMEM; if (myfd) (void)close(fd); return (-2); } which clearly does the right thing, except for freeing the old record.... There are other cases where this is the case. I've not looked at the non-lib parts of the tree. Warner 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?199808202221.QAA25040>