[net.bugs.4bsd] NULL pointer dereferencing and printf

minow@decvax.UUCP (Martin Minow) (01/27/84)

This discussion seems to pop up once a year -- perhaps it could
be put in net.announce and be done with.  You shouldn't dereference
NULL.

But people do -- mostly by accident.  As a slight debugging aid,
the Decus C printf (and, I think, the V6 printf) test for
printf("%s", NULL) and print "{null}".  This at least keeps
the bug from being fatal.  Vax-11 C crashes the program which
gets the bug out quicker, I suppose.

(Actually, on Vax, the first 512 bytes of the user
address space can't be referenced, so most instances
of ((struct foo *) NULL)->bar are caught, too.

Martin Minow
decvax!minow