From 5f814682b48c59f07568d349f979eed4cf306703 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 28 Sep 2011 22:07:58 -0400 Subject: don't crash on null strings in printf passing null pointer for %s is UB but lots of broken programs do it anyway --- src/stdio/vfprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 4c990e5e..b5001ff2 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -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; -- cgit v1.2.1