ruby-changes:5690
From: shyouhei <ko1@a...>
Date: Sun, 15 Jun 2008 19:54:15 +0900 (JST)
Subject: [ruby-changes:5690] Ruby:r17196 (ruby_1_8_5): merge revision(s) 15645:15647:
shyouhei 2008-06-15 19:54:01 +0900 (Sun, 15 Jun 2008) New Revision: 17196 Modified files: branches/ruby_1_8_5/ChangeLog branches/ruby_1_8_5/bignum.c branches/ruby_1_8_5/test/ruby/test_bignum.rb branches/ruby_1_8_5/version.h Log: merge revision(s) 15645:15647: * bignum.c (big2str_find_n1): check integer overflow. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/test/ruby/test_bignum.rb?r1=17196&r2=17195&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/version.h?r1=17196&r2=17195&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/bignum.c?r1=17196&r2=17195&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/ChangeLog?r1=17196&r2=17195&diff_format=u Index: ruby_1_8_5/ChangeLog =================================================================== --- ruby_1_8_5/ChangeLog (revision 17195) +++ ruby_1_8_5/ChangeLog (revision 17196) @@ -1,3 +1,7 @@ +Sun Jun 15 19:53:16 2008 Nobuyoshi Nakada <nobu@r...> + + * bignum.c (big2str_find_n1): check integer overflow. + Sun Jun 15 19:51:37 2008 Tanaka Akira <akr@f...> * gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857] Index: ruby_1_8_5/version.h =================================================================== --- ruby_1_8_5/version.h (revision 17195) +++ ruby_1_8_5/version.h (revision 17196) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-06-15" #define RUBY_VERSION_CODE 185 #define RUBY_RELEASE_CODE 20080615 -#define RUBY_PATCHLEVEL 182 +#define RUBY_PATCHLEVEL 183 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 Index: ruby_1_8_5/bignum.c =================================================================== --- ruby_1_8_5/bignum.c (revision 17195) +++ ruby_1_8_5/bignum.c (revision 17196) @@ -636,6 +636,9 @@ if (BIGZEROP(x)) { return rb_str_new2("0"); } + if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) { + rb_raise(rb_eRangeError, "bignum too big to convert into `string'"); + } j = SIZEOF_BDIGITS*CHAR_BIT*i; switch (base) { case 2: break; Index: ruby_1_8_5/test/ruby/test_bignum.rb =================================================================== --- ruby_1_8_5/test/ruby/test_bignum.rb (revision 17195) +++ ruby_1_8_5/test/ruby/test_bignum.rb (revision 17196) @@ -84,4 +84,12 @@ shift_test(-4518325415524767873) shift_test(-0xfffffffffffffffff) end + + def test_too_big_to_s + if (big = 2**31-1).is_a?(Fixnum) + return + end + e = assert_raise(RangeError) {(1 << big).to_s} + assert_match(/too big to convert/, e.message) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/