This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/9819] readdir segmentation faults when passed NULL


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]