Re: strdup(NULL) supposed to create SIGSEGV?

看板FB_hackers作者時間17年前 (2008/04/24 02:49), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串18/25 (看更多)
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. _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
文章代碼(AID): #183uJM00 (FB_hackers)
討論串 (同標題文章)
文章代碼(AID): #183uJM00 (FB_hackers)