summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorClayton Smith <[email protected]>2016-12-15 09:36:22 -0500
committerClayton Smith <[email protected]>2016-12-15 09:36:22 -0500
commit868d2e528fce86f380a2d099877f6cb8ffd1ff69 (patch)
tree617a933cf0a26f6b5b688172e09dcc236f1b27d8 /src/string.c
parent73cc08772f1a11140b238525698bce0664326a50 (diff)
downloadmruby-868d2e528fce86f380a2d099877f6cb8ffd1ff69.tar.gz
mruby-868d2e528fce86f380a2d099877f6cb8ffd1ff69.zip
Fix crash when exponent is -2147483648
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c
index 0049fdd5b..ce27cdaa1 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2868,7 +2868,11 @@ mrb_float_read(const char *string, char **endPtr)
mantSize -= 1; /* One of the digits was the point. */
}
if (mantSize > 18) {
- fracExp = decPt - 18;
+ if (decPt - 18 > 29999) {
+ fracExp = 29999;
+ } else {
+ fracExp = decPt - 18;
+ }
mantSize = 18;
} else {
fracExp = decPt - mantSize;
@@ -2922,6 +2926,9 @@ mrb_float_read(const char *string, char **endPtr)
}
while (isdigit(*p)) {
exp = exp * 10 + (*p - '0');
+ if (exp > 19999) {
+ exp = 19999;
+ }
p += 1;
}
}