[PATCH] fix null pointer in mtrace

Florian Weimer fweimer@redhat.com
Tue Nov 12 10:42:00 GMT 2019


* liqingqing:

> I had tested this scenario, it seems like that the fprintf and other
> file operation function do not check the invalid argument like the
> null pointer.  does any one knows why fprintf do not check the input?

It's not required by the standard because violating preconditions
results in undefined behavior.  Sloppily written code with such bugs
tends to not check error returns from functions, either.  This means if
we added a null check for the stream argument to fprintf (e.g., failing
with EINVAL in that case), it would only obscure the problem and make
diagnosis even more difficult.

Thanks,
Florian



More information about the Libc-alpha mailing list