diff --git a/src/stdio/__scanf.c b/src/stdio/__scanf.c index 185615d..6e4bd4c 100644 --- a/src/stdio/__scanf.c +++ b/src/stdio/__scanf.c @@ -99,8 +99,10 @@ int __scanf(rctx_t *r, const wchar_t *fmt, va_list ap) } else if (*p != '%' || p[1] == '%') { if (*p == '%') p++; r->w = 1; - if (*p++ != read(r)) + if (*p++ != read(r)) { + if(r->c == -1) matches = -1; goto match_fail; + } continue; } p++; @@ -126,7 +128,7 @@ int __scanf(rctx_t *r, const wchar_t *fmt, va_list ap) } else if (mode == 1) { dest = va_arg(ap, void *); } - + if (!*p) goto fmt_fail; width = 0; @@ -474,6 +476,7 @@ writefloat: /* unread will do nothing if field width was exhausted */ unread(r); if (dest) matches++; + else(r->u = 0); //prevent bad size returned with follow-up %n } return matches; enc_fail: