NULL pointer dereferencing and printf

Martin Minow minow at decvax.UUCP
Fri Jan 27 12:45:24 AEST 1984


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



More information about the Comp.bugs.4bsd.ucb-fixes mailing list