X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__scanf.c;h=062327d75c5851e7b014bb5e03742e19e6ab1409;hb=aed707f679cce80afd929f0efaf080f1e8481330;hp=185615d3a5097b8ea3904539825af956ce2dd5ff;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/stdio/__scanf.c b/src/stdio/__scanf.c index 185615d3..062327d7 100644 --- a/src/stdio/__scanf.c +++ b/src/stdio/__scanf.c @@ -22,8 +22,7 @@ static int read(rctx_t *r) static void unread(rctx_t *r) { - //if (r->u || r->w < 0) return; - if (r->w < 0) return; + if (r->c < 0 || r->w < 0) return; r->w++; r->u = 1; } @@ -99,7 +98,9 @@ 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 ((c = read(r)) < 0) + goto input_fail; + if (*p++ != c) goto match_fail; continue; }