mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-01-30 16:41:05 +08:00
float.c: correct exponent capping
Actually enforce the exponent capping, as opposed to only enforcing it to within a factor of 10. Furthermore, continue to scan the string in order to check for invalid characters. Finally, 16384 is too tight of a bound for a binary exponent: it's a tight bound, but the shift added due to the digit string can move the cap into the active region (±16383). Thus, change it to 20000 to be on the safe side.
This commit is contained in:
parent
b0e1d423dd
commit
3b2ad1bc37
7
float.c
7
float.c
@ -141,9 +141,8 @@ static int32_t read_exponent(const char *string, int32_t max)
|
||||
* in single, double, and extended precision, but
|
||||
* sufficient to avoid signed integer wraparound.
|
||||
*/
|
||||
if (i > max) {
|
||||
break;
|
||||
}
|
||||
if (i > max)
|
||||
i = max;
|
||||
} else if (*string == '_') {
|
||||
/* do nothing */
|
||||
} else {
|
||||
@ -494,7 +493,7 @@ static bool ieee_flconvert_hex(const char *string, uint16_t * mant,
|
||||
}
|
||||
} else if (c == 'p' || c == 'P') {
|
||||
int32_t e;
|
||||
e = read_exponent(string, 16384);
|
||||
e = read_exponent(string, 20000);
|
||||
if (e == INT32_MAX)
|
||||
return false;
|
||||
twopwr += e;
|
||||
|
Loading…
Reference in New Issue
Block a user