summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 21:27:22 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-15 21:27:22 +0000
commit9f53bcf67c9b880c1f0aed5c6999247556717626 (patch)
tree0e387389083a628ffaf0e2c9808dca217dd38a35
parent379478e0c2c00cda7a587b1d2ef74b8995bee312 (diff)
* bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@13019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c4
-rw-r--r--version.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 88baa72660..d4bcc30802 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Aug 16 06:26:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
+
Thu Aug 16 06:25:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_succ): Time#succ should return a time object in the
diff --git a/bignum.c b/bignum.c
index 0ff4b4e19f..489ae77b2e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1611,8 +1611,10 @@ rb_big_pow(x, y)
yy = FIX2LONG(y);
if (yy > 0) {
VALUE z = x;
+ const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS;
- if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) {
+ if ((RBIGNUM(x)->len > BIGLEN_LIMIT) ||
+ (RBIGNUM(x)->len > BIGLEN_LIMIT / yy)) {
rb_warn("in a**b, b may be too big");
d = (double)yy;
break;
diff --git a/version.h b/version.h
index acfaf68fe9..0a6ccf6b7c 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2007-08-16"
#define RUBY_VERSION_CODE 185
#define RUBY_RELEASE_CODE 20070816
-#define RUBY_PATCHLEVEL 78
+#define RUBY_PATCHLEVEL 79
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8