[前][次][番号順一覧][スレッド一覧]

ruby-changes:1695

From: ko1@a...
Date: 22 Aug 2007 10:32:27 +0900
Subject: [ruby-changes:1695] shyouhei - Ruby:r13186 (ruby_1_8_6): * bignum.c (rb_big_pow): refine overflow check.

shyouhei	2007-08-22 10:32:19 +0900 (Wed, 22 Aug 2007)

  New Revision: 13186

  Modified files:
    branches/ruby_1_8_6/ChangeLog
    branches/ruby_1_8_6/bignum.c
    branches/ruby_1_8_6/version.h

  Log:
    * bignum.c (rb_big_pow): refine overflow check.  [ruby-dev:31242]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/ChangeLog?r1=13186&r2=13185
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/version.h?r1=13186&r2=13185
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/bignum.c?r1=13186&r2=13185

Index: ruby_1_8_6/ChangeLog
===================================================================
--- ruby_1_8_6/ChangeLog	(revision 13185)
+++ ruby_1_8_6/ChangeLog	(revision 13186)
@@ -1,3 +1,7 @@
+Wed Aug 22 10:29:45 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* bignum.c (rb_big_pow): refine overflow check.  [ruby-dev:31242]
+
 Wed Aug 22 10:26:59 2007  Yukihiro Matsumoto  <matz@r...>
 
 	* time.c (time_succ): Time#succ should return a time object in the
Index: ruby_1_8_6/version.h
===================================================================
--- ruby_1_8_6/version.h	(revision 13185)
+++ ruby_1_8_6/version.h	(revision 13186)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2007-08-22"
 #define RUBY_VERSION_CODE 186
 #define RUBY_RELEASE_CODE 20070822
-#define RUBY_PATCHLEVEL 69
+#define RUBY_PATCHLEVEL 70
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_6/bignum.c
===================================================================
--- ruby_1_8_6/bignum.c	(revision 13185)
+++ ruby_1_8_6/bignum.c	(revision 13186)
@@ -1646,8 +1646,10 @@
 	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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]