فهرست منبع

add printing of null %s arguments as "(null)" in wide printf

this is undefined, but supported in our implementation of the normal
printf, so for consistency the wide variant should support it too.
Rich Felker 10 سال پیش
والد
کامیت
f8f565df46
1فایلهای تغییر یافته به همراه1 افزوده شده و 0 حذف شده
  1. 1 0
      src/stdio/vfwprintf.c

+ 1 - 0
src/stdio/vfwprintf.c

@@ -296,6 +296,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
 		case 'm':
 		case 'm':
 			arg.p = strerror(errno);
 			arg.p = strerror(errno);
 		case 's':
 		case 's':
+			if (!arg.p) arg.p = "(null)";
 			bs = arg.p;
 			bs = arg.p;
 			if (p<0) p = INT_MAX;
 			if (p<0) p = INT_MAX;
 			for (i=l=0; l<p && (i=mbtowc(&wc, bs, MB_LEN_MAX))>0; bs+=i, l++);
 			for (i=l=0; l<p && (i=mbtowc(&wc, bs, MB_LEN_MAX))>0; bs+=i, l++);