This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: strlen on a NULL
- Subject: Re: strlen on a NULL
- From: Paul Shirley <Paul at chocolat dot foobar dot co dot uk>
- Date: Wed, 13 May 1998 22:54:04 +0100
- Cc: gnu-win32 at cygnus dot com
In message <199805130145.LAA18828@mali.comdyn.com.au>, raf
<raf@comdyn.com.au> writes
>nonsense. if strlen() doesn't crash when given a null pointer, the only
>reason is that the implementation must contain a test for the null pointer.
Or memory is mapped and unprotected at 0, and theres a terminating zero
somewhere before unmapped/protected memory.
>this is atypical. strlen(NULL) normally crashes on unix. unix core files
>may start at address zero, but zero is an illegal address. this is deliberate.
>using null pointers is so common an error in c programming, that the null
>address was deemed to always be invalid. remember that c and unix were
>invented together.
Using NULL in most libc functions has *undefined* behaviour. Accessing
at :NULL is not illegal in C, just a very bad idea.
On my Atari ST :0 is protected, on my Playstation its not. I get an
exception on the ST and trap the code that caused it, my Playstation
crashes sometime later that day for no obvious reason ;)
You just got lucky with Win32 trapping NULL access, be grateful.
--
Paul Shirley
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".