author | Rich Felker <dalias@aerifal.cx> | 2025年09月19日 18:35:19 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2025年09月19日 18:35:19 -0400 |
commit | 0ccaf0572e9cccda2cced0f7ee659af4c1c6679a (patch) | |
tree | e023b5f4c8e5fe972514e948c7f06773937d5bb5 | |
parent | 0b86d60badad6a69b37fc06d18b5763fbbf47b58 (diff) | |
download | musl-master.tar.gz |
-rw-r--r-- | src/stdio/vfprintf.c | 4 |
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index a68edabb..514a44dd 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -182,7 +182,9 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t, int ps) { int max_mant_dig = (ps==BIGLPRE) ? LDBL_MANT_DIG : DBL_MANT_DIG; int max_exp = (ps==BIGLPRE) ? LDBL_MAX_EXP : DBL_MAX_EXP; - int max_mant_slots = (max_mant_dig+28)/29 + 1; + /* One slot for 29 bits left of radix point, a slot for every 29-21=8 + * bits right of the radix point, and one final zero slot. */ + int max_mant_slots = 1 + (max_mant_dig-29+7)/8 + 1; int max_exp_slots = (max_exp+max_mant_dig+28+8)/9; int bufsize = max_mant_slots + max_exp_slots; uint32_t big[bufsize]; |