This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] fix null pointer in mtrace
On 2019/11/12 18:41, Florian Weimer wrote:
> * 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
>
clear, thank you Florian