Дана 24/04/07 10:11AM, Stuart Henderson написа:
> Yes. It's very common though, especially when constructing strings for
> debug logging. I see this a lot with software in the GNOME ecosystem
> using sprintf for this.

Programmers who pass NULL to %s format specifier are writing incorrect code, 
whatever project they are contributing to. Mainstream projects like GNOME are 
a mess, and only getting worse with every iteration anyway.


> That's interesting about the compiler optimisation for printf->puts,
> though I think it won't be used in many cases where the pointer nay be
> null so many uses of this won't trigger crashes for that reason.

Keep in mind the quoted answer states this about gcc. I'm not sure about 
Clang/LLVM. In any case, passing NULL to %s specifier in *printf is incorrect 
code.

Reply via email to