ruby-changes:5692
From: shyouhei <ko1@a...>
Date: Sun, 15 Jun 2008 19:55:23 +0900 (JST)
Subject: [ruby-changes:5692] Ruby:r17198 (ruby_1_8_6): merge revision(s) 15645:15647:
shyouhei 2008-06-15 19:55:07 +0900 (Sun, 15 Jun 2008) New Revision: 17198 Modified files: branches/ruby_1_8_6/ChangeLog branches/ruby_1_8_6/bignum.c branches/ruby_1_8_6/test/ruby/test_bignum.rb branches/ruby_1_8_6/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_6/ChangeLog?r1=17198&r2=17197&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/version.h?r1=17198&r2=17197&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/test/ruby/test_bignum.rb?r1=17198&r2=17197&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/bignum.c?r1=17198&r2=17197&diff_format=u Index: ruby_1_8_6/ChangeLog =================================================================== --- ruby_1_8_6/ChangeLog (revision 17197) +++ ruby_1_8_6/ChangeLog (revision 17198) @@ -1,3 +1,7 @@ +Sun Jun 15 19:54:21 2008 Nobuyoshi Nakada <nobu@r...> + + * bignum.c (big2str_find_n1): check integer overflow. + Sun Jun 15 19:52:20 2008 Tanaka Akira <akr@f...> * gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857] Index: ruby_1_8_6/version.h =================================================================== --- ruby_1_8_6/version.h (revision 17197) +++ ruby_1_8_6/version.h (revision 17198) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-06-15" #define RUBY_VERSION_CODE 186 #define RUBY_RELEASE_CODE 20080615 -#define RUBY_PATCHLEVEL 183 +#define RUBY_PATCHLEVEL 184 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 Index: ruby_1_8_6/bignum.c =================================================================== --- ruby_1_8_6/bignum.c (revision 17197) +++ ruby_1_8_6/bignum.c (revision 17198) @@ -652,6 +652,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_6/test/ruby/test_bignum.rb =================================================================== --- ruby_1_8_6/test/ruby/test_bignum.rb (revision 17197) +++ ruby_1_8_6/test/ruby/test_bignum.rb (revision 17198) @@ -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/