Subject: Re: sanity checking arguments to library functions...
To: Guenther Grau <Guenther.Grau@bk.bosch.de>
From: Richard Rauch <rauch@eecs.ukans.edu>
List: tech-userlevel
Date: 04/13/1999 13:24:02
On Tue, 13 Apr 1999, Guenther Grau wrote:
> Luke Mewburn wrote:
> >
> > an idea that came up a while ago was to add stuff to all libc functions
> > to sanity check arguments (e.g, fgets(char *buf, int n, FILE *fp) having
> > buf != NULL && fp != NULL, etc)
> >
> > i think this is a good idea, and unless it breaks standards, we should
>
> I don't think it breaks any standards. The standards usually just say:
> Behaviour will be undefined, if a null pointer is passed. "Undefined"
> maens we can do anything :-) AFAIK, there are a few rare cases where
> passing a null pointer is allowed (fclose?, don't have the man pages
> handy), which would have to be allowed, of course.
I think that free(NULL) is stated to ``do nothing''. I remember sending
an bug-report to a compiler-author who apparently chose to suspend the
process permamently. I commented that while he was arguably in spec, I
did not think that that was the intention...
(^&
"I probably don't know what I'm talking about." --rauch@eecs.ukans.edu