Date: Wed, 23 Apr 2008 12:43:51 -0400 From: Mike Meyer <mwm@mired.org> To: Roman Divacky <rdivacky@freebsd.org> Cc: Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org>, Garrett Cooper <yanefbsd@gmail.com>, hackers@freebsd.org Subject: Re: strdup(NULL) supposed to create SIGSEGV? Message-ID: <20080423124351.426627d3@mbook-fbsd> In-Reply-To: <20080423162635.GA42593@freebsd.org> References: <7d6fde3d0804222240j6b42b77yd86d8accb5a959fa@mail.gmail.com> <20080423025048.6b51a580@bhuda.mired.org> <5F412E73-29FC-4876-A6F0-9BC269876192@bitpowder.com> <20080423113951.020f0130@mbook-fbsd> <20080423162635.GA42593@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 23 Apr 2008 18:26:35 +0200 Roman Divacky <rdivacky@freebsd.org> wrote: > > I think someone gave the reason I'm about to: trying to copy a NULL > > pointer means I have a bug somewhere earlier in my code that will > > eventually produce visibly wrong results - a segfault being such. The > > sooner that happens after the bug, the less code I have to search to > > find it, the better for me. > > if only the fix was something else than > > if (ptr != NULL) > strdup(ptr); > > :) Again, under what conditions would this "fix" be considered correct? I.e. - when does it make sense to try and duplicate a string that isn't? <mike -- Mike Meyer <mwm@mired.org> http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080423124351.426627d3>