fix uninitialized var in vfwprintf printing 0-prec string
authorRich Felker <dalias@aerifal.cx>
Fri, 4 May 2012 05:26:43 +0000 (01:26 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 4 May 2012 05:26:43 +0000 (01:26 -0400)
this could lead to spurious failures of wide printf functions

src/stdio/vfwprintf.c

index 42ce304fb053e5fc2a6c466a236bb7dbc1459ab9..62829806b10386a908296b3bef602bc49ac50f15 100644 (file)
@@ -292,7 +292,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
                case 's':
                        bs = arg.p;
                        if (p<0) p = INT_MAX;
-                       for (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++);
                        if (i<0) return -1;
                        p=l;
                        if (w<p) w=p;