A zero pointer is not a null pointer
Posted Jul 21, 2009 10:57 UTC (Tue) by
epa (subscriber, #39769)
Parent article:
Fun with NULL pointers, part 1
Since the zero page can be mapped and therefore 0x0 is a valid address, the zero bit pattern should not be used for the null pointer. The null pointer is supposed to be an invalid pointer that never points to any addressable memory. From the C99 standard:
If a null pointer constant is converted to a
pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.
The C runtime should use some other magic value to represent the null pointer - and the kernel should promise never to map any addressable memory there.
(
Log in to post comments)