提交 5f814682 编写于 作者: R Rich Felker

don't crash on null strings in printf

passing null pointer for %s is UB but lots of broken programs do it anyway
上级 de543b05
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册