Subject: Re: strlen on a NULL
From: [email-masked] (Paul Shirley)

15 May 1998 09:57:57 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Cc: [email-masked]

In message <[email-masked]>, raf
<[email-masked]> 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
"[email-masked]" with one line of text: "help".