Date: Tue, 22 Oct 1996 18:12:44 +1000 (EST) From: "Daniel O'Callaghan" <danny@panda.hilink.com.au> To: freebsd-hackers@freebsd.org Subject: libc string routines don't check for NULL pointers Message-ID: <Pine.BSF.3.91.961022180422.548J-100000@panda.hilink.com.au>
next in thread | raw e-mail | index | archive | help
The string comparison (and other) routines in libc don't check for null pointers being passed. This results in SEGVs if one or both of the string pointers being passed is NULL. I can see a religious debate here, but I'm going to raise the issue: Should str*cmp() handle NULL arguments. I have made the very simple change necessary to strcmp() for it to return 0 - strings are the same, or pointers are both NULL < 0 - s1 < s2, or s1 == NULL > 0 - s1 > s2 or s2 == NULL I'd like to see my changes made to libc, but what do others think - should it be just "the programmer's stupid fault" if (s)he passes a NULL pointer to these routines, or should the routines handle NULL? Danny
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.961022180422.548J-100000>