summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-06 00:46:48 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-06 00:46:48 (GMT)
commit0ed5aee00074547ed58c55bef6d346a9a4dd4925 (patch)
treec9b1c4c1a6ffb58d759047c6ce284b28f71d524f /util.c
parentfab386fbff87a6fe3fa6d8521e0948b34be6a941 (diff)
* util.c (ruby_strtod): check integr overflow.
[ruby-dev:42180] #3789 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/util.c b/util.c
index 762d97f..9d10498 100644
--- a/util.c
+++ b/util.c
@@ -2143,12 +2143,17 @@ break2:
nd = 0;
c = *s;
- if (c < '0' || '9' < c) goto ret0;
- do {
- nd *= 10;
- nd += c;
- nd -= '0';
- c = *++s;
+ if (c < '0' || '9' < c) goto ret0;
+ do {
+ nd *= 10;
+ nd += c;
+ nd -= '0';
+ c = *++s;
+ /* Float("0x0."+("0"*267)+"1fp2095") */
+ if (abs(nd) > 2095) {
+ while ('0' <= c && c <= '9') c = *++s;
+ break;
+ }
} while ('0' <= c && c <= '9');
dval(rv) = ldexp(adj, nd * dsign);
}