This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/9819] readdir segmentation faults when passed NULL
- From: "jg at jguk dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Sun, 13 Nov 2011 00:51:12 +0000
- Subject: [Bug libc/9819] readdir segmentation faults when passed NULL
- Auto-submitted: auto-generated
- References: <bug-9819-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=9819
--- Comment #8 from Jon Grant <jg at jguk dot org> 2011-11-13 00:51:12 UTC ---
C standard specifies:
"The macro NULL is defined in <stddef.h> (and other headers) as a null pointer
constant; see 7.17."
It's in stddef.h, NULL is not an uninitialised value, NULL is a part of the
language. It's often set by the developer, and other times it's returned by
functions like fopen. For these reasons the "null pointer constant" is
provided, to be checked, not to be a feature of the language that is ignored.
Re read vs fread, I would have thought if(NULL == ptr) would be exactly the
same 4 instruction cost that it is in the user space as kernel.
If read() checking for NULL + returning error code is not standard, really it
should be IMHO. Could be in the POSIX standard.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.