From: Rich Felker Date: Fri, 17 Aug 2012 20:53:09 +0000 (-0400) Subject: fix float parsing logic for long decimal expansions X-Git-Tag: v0.9.4~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=11458e5b098319cf3e2d05c8cbaa74d58db740e3;p=oweals%2Fmusl.git fix float parsing logic for long decimal expansions this affects at least the case of very long inputs, but may also affect shorter inputs that become long due to growth while upscaling. basically, the logic for the circular buffer indices of the initial base-10^9 digit and the slot one past the final digit, and for simplicity of the loop logic, assumes an invariant that they're not equal. the upscale loop, which can increase the length of the base-10^9 representation, attempted to preserve this invariant, but was actually only ensuring that the end index did not loop around past the start index, not that the two never become equal. the main (only?) effect of this bug was that subsequent logic treats the excessively long number as having no digits, leading to junk results. --- diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index 68f576c9..bba5753b 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -199,11 +199,11 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po } if (carry) { rp += 9; + a = (a-1 & MASK); if (a == z) { z = (z-1 & MASK); x[z-1 & MASK] |= x[z]; } - a = (a-1 & MASK); x[a] = carry; } }