summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c4
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a716ecd95..1363cf2118 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jul 18 16:57:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
+
Wed Jul 18 08:47:09 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 5763e8c72f..16fbe86527 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1755,8 +1755,10 @@ rb_big_pow(x, y)
if (yy > 0) {
VALUE z = 0;
long mask;
+ 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;