fix off-by-one error that caused uninitialized memory read in floatscan
authorRich Felker <dalias@aerifal.cx>
Mon, 30 Apr 2012 06:56:47 +0000 (02:56 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 30 Apr 2012 06:56:47 +0000 (02:56 -0400)
this caused misreading of certain floating point values that are exact
multiples of large powers of ten, unpredictable depending on prior
stack contents.

src/internal/floatscan.c

index f80db38..4b335f5 100644 (file)
@@ -244,7 +244,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
 
        /* Assemble desired bits into floating point variable */
        for (y=i=0; i<LD_B1B_DIG; i++) {
-               if ((a+i & MASK)==z) x[z=(z+1 & MASK)] = 0;
+               if ((a+i & MASK)==z) x[(z=(z+1 & MASK))-1] = 0;
                y = 1000000000.0L * y + x[a+i & MASK];
        }