mirror of
git://git.musl-libc.org/musl
synced 2024-12-17 20:24:54 +00:00
don't crash on null strings in printf
passing null pointer for %s is UB but lots of broken programs do it anyway
This commit is contained in:
parent
de543b05c8
commit
5f814682b4
@ -584,7 +584,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
|
||||
case 'm':
|
||||
if (1) a = strerror(errno); else
|
||||
case 's':
|
||||
a = arg.p;
|
||||
a = arg.p ? arg.p : "(null)";
|
||||
z = memchr(a, 0, p);
|
||||
if (!z) z=a+p;
|
||||
else p=z-a;
|
||||
|
Loading…
Reference in New Issue
Block a user