Re: strdup(NULL) supposed to create SIGSEGV?

看板FB_hackers作者時間17年前 (2008/04/23 19:21), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串9/25 (看更多)
>Yes, it's supposed to segfault. Check out what, say, strcpy does if >you ask it to copy a NULL pointer. And this is an improvement from the >bad old days, when they would happily walk through memory starting at >0..... >Besides, errno is used to signal errors from system calls. strdup >isn't a system call, it's a library function (says so at the top of >the man page). >Do you have examples of systems where strdup doesn't behave this way? According to Open Group strdup should return NULL and set errno. Look at: http://www.opengroup.org/onlinepubs/009695399/functions/strdup.html There is no valid argument for doing segfault instead of above behavior. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ _______________________________________________ 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): #183nk-00 (FB_hackers)
討論串 (同標題文章)
文章代碼(AID): #183nk-00 (FB_hackers)