commit | 5f814682b48c59f07568d349f979eed4cf306703 | [log] [tgz] |
---|---|---|
author | Rich Felker <dalias@aerifal.cx> | Wed Sep 28 22:07:58 2011 -0400 |
committer | Rich Felker <dalias@aerifal.cx> | Wed Sep 28 22:07:58 2011 -0400 |
tree | 3e57d7d65a8329d87ea41232f8689b5fd64efd7b | |
parent | de543b05c87d79a9313991810e9ee8ecdaad8f19 [diff] |
don't crash on null strings in printf passing null pointer for %s is UB but lots of broken programs do it anyway
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 4c990e5..b5001ff 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c
@@ -584,7 +584,7 @@ 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;