summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-10-21 15:32:33 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-10-21 15:33:01 -0700
commit3b2ad1bc370653e90d6b2fa9cfc587a7aea405f3 (patch)
treeb7702e30f7c00622e5a5e3b072b35e5cae6abb25
parentb0e1d423dd3e174a92a1d7256aec4e9b701ece3c (diff)
downloadnasm-3b2ad1bc370653e90d6b2fa9cfc587a7aea405f3.tar.gz
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.
-rw-r--r--float.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/float.c b/float.c
index db641800..843dbdfa 100644
--- a/float.c
+++ b/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;