Opened 9 years ago

Closed 9 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/ Version: R1/alpha2
Keywords: printf null-string Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All


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 mr.Noisy, 9 years ago

Keywords: null-string added; null-char removed

comment:2 by mr.Noisy, 9 years ago

First call of printf() function puts (null) to the stdout.

comment:3 by phoudoin, 9 years ago

Resolution: invalid
Status: newclosed

The culprid is gcc, which optimized printf("%s\n", arg) call into puts(arg)

See here:

Can't be fixed by Haiku in libroot.

One workaround: use gcc's -fno-builtin-printf option.

Version 1, edited 9 years ago by phoudoin (previous) (next) (diff)
Note: See TracTickets for help on using tickets.