Opened 14 years ago
Closed 14 years ago
#7231 closed bug (invalid)
Some issues with handling null-string arguments in printf()
Reported by: | mr.Noisy | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | System/libroot.so | Version: | R1/alpha2 |
Keywords: | libroot.so printf null-string | Cc: | |
Blocked By: | Blocking: | ||
Platform: | All |
Description
The program
#include <cstdio> int main() { char* p = 0; printf("%s \n", p); printf("%s\n", p); return 0; }
will crash on second printf. Haiku hrev40200 GCC4 Hybrid
Change History (3)
comment:1 by , 14 years ago
Keywords: | null-string added; null-char removed |
---|
comment:2 by , 14 years ago
comment:3 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The culprid is gcc, which optimize printf("%s\n", arg) into puts(arg).
See here:
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15685
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25609
This can't be fixed in libroot. Sorry. One workaround: use gcc's -fno-builtin-printf option.
Note:
See TracTickets
for help on using tickets.
First call of printf() function puts (null) to the stdout.