fix overread (consuming an extra byte) scanning NAN
authorRich Felker <dalias@aerifal.cx>
Sat, 21 Apr 2012 15:57:39 +0000 (11:57 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 21 Apr 2012 15:57:39 +0000 (11:57 -0400)
bug detected by glib test suite

src/internal/floatscan.c

index 7381e9a4108aa9d0714a90d95586e99d122ae4cc..b260381e7eb5f44041c1900a7bca695feb947505 100644 (file)
@@ -436,7 +436,7 @@ long double __floatscan(FILE *f, int prec, int pok)
                return sign * INFINITY;
        }
        if (!i) for (i=0; i<3 && (c|32)=="nan"[i]; i++)
-               if (i<3) c = shgetc(f);
+               if (i<2) c = shgetc(f);
        if (i==3) {
                return NAN;
        }