strdup(NULL) supposed to create SIGSEGV?
Hi all,
I made an oops in a program, which uncovered "feature" in strdup(2)
that I wasn't aware of before. So I was wondering, is strdup(pointer = NULL)
supposed to segfault should this just return NULL and set errno?
Good news is that Linux does the same thing (yay?), so at least FreeBSD
isn't alone..
Sample:
[gcooper@optimus ~]$ ss="strdup_segfault"; gcc -o $ss $ss.c; ./$ss; cat
$ss.c
Segmentation fault: 11 (core dumped)
#include <string.h>
int
main() {
const char *null_src_p = NULL;
char *null_dest_p = strdup(null_src_p);
return 0;
}
My sources are a bit old (last sync and userland recompile was mid~March)
but I don't think that libc changes all that often.
[gcooper@optimus ~]$ uname -a
FreeBSD optimus 8.0-CURRENT FreeBSD 8.0-CURRENT #10: Wed Apr 16 19:47:39 PDT
200
8 root@optimus:/usr/obj/usr/src/sys/OPTIMUS i386
Thanks,
-Garrett
_______________________________________________
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"
討論串 (同標題文章)
完整討論串 (本文為第 1 之 25 篇):