Perhaps another way to look at this issue is that the libc library is at fault 
for dereferencing the NULL pointer in printf.  There is no need for it do 
dereference the pointer, as it can (and should) check for NULL first.  

I think that passing NULL to formatting functions for %s should not crash, (ala 
glibc) as  NULL is a perfectly legal value for a string.  It is the same as 
passing the results of 1.0 /0.0 to a %f.  The formating functions convert that 
to "Inf", why shouldn't they convert NULL %s as "(NULL)" as well?

However dereferencing NULL SHOULD crash, and the [EMAIL PROTECTED] library 
prevents this.  Thus the [EMAIL PROTECTED] library is not a solution to the 
NULL formatting problem.

Formatting a NULL %s shouldn't cause a crash.  Dereferencing a NULL pointer 
should.  For those who argue program correctness, most likly a program that 
prints a NULL string will then try to use it later, and it will crash then.  
Seeing the "(NULL)" printed in the output would help with the fix.  

--Andy Spitzer
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to