Opened 13 years ago

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

Keywords: null-string added; null-char removed

comment:2 by mr.Noisy, 13 years ago

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

comment:3 by phoudoin, 13 years ago

Resolution: invalid
Status: newclosed

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

See here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15685

Can't be fixed in libroot.

Version 0, edited 13 years ago by phoudoin (next)
Note: See TracTickets for help on using tickets.