From 868d2e528fce86f380a2d099877f6cb8ffd1ff69 Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 15 Dec 2016 09:36:22 -0500 Subject: Fix crash when exponent is -2147483648 --- src/string.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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; } } -- cgit v1.2.3