strdup(NULL) supposed to create SIGSEGV?

Roman Divacky rdivacky at freebsd.org
Wed Apr 23 16:27:09 UTC 2008


> 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);

:)


More information about the freebsd-hackers mailing list