ruby-changes:16873
From: nobu <ko1@a...>
Date: Thu, 5 Aug 2010 18:40:25 +0900 (JST)
Subject: [ruby-changes:16873] Ruby:r28869 (trunk): * complex.c (nucomp_marshal_load): should check the argument.
nobu 2010-08-05 18:36:16 +0900 (Thu, 05 Aug 2010) New Revision: 28869 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28869 Log: * complex.c (nucomp_marshal_load): should check the argument. [ruby-core:31622] * rational.c (nurat_marshal_load): ditto Modified files: trunk/ChangeLog trunk/complex.c trunk/rational.c trunk/test/ruby/test_complex.rb trunk/test/ruby/test_rand.rb trunk/test/ruby/test_rational.rb Index: complex.c =================================================================== --- complex.c (revision 28868) +++ complex.c (revision 28869) @@ -1247,6 +1247,7 @@ nucomp_marshal_load(VALUE self, VALUE a) { get_dat1(self); + Check_Type(a, T_ARRAY); dat->real = RARRAY_PTR(a)[0]; dat->imag = RARRAY_PTR(a)[1]; rb_copy_generic_ivar(self, a); Index: ChangeLog =================================================================== --- ChangeLog (revision 28868) +++ ChangeLog (revision 28869) @@ -1,5 +1,10 @@ -Thu Aug 5 18:25:33 2010 Nobuyoshi Nakada <nobu@r...> +Thu Aug 5 18:36:11 2010 Nobuyoshi Nakada <nobu@r...> + * complex.c (nucomp_marshal_load): should check the argument. + [ruby-core:31622] + + * rational.c (nurat_marshal_load): ditto + * marshal.c (w_float): should not append a dot if no fractal part exists. [ruby-dev:41936] Index: test/ruby/test_rand.rb =================================================================== --- test/ruby/test_rand.rb (revision 28868) +++ test/ruby/test_rand.rb (revision 28869) @@ -427,4 +427,11 @@ assert_equal(x0, x2) end end + + def test_marshal + bug3656 = '[ruby-core:31622]' + assert_raise(TypeError, bug3656) { + Random.new.marshal_load(0) + } + end end Index: test/ruby/test_complex.rb =================================================================== --- test/ruby/test_complex.rb (revision 28868) +++ test/ruby/test_complex.rb (revision 28869) @@ -633,6 +633,11 @@ assert_equal(c, c2) assert_instance_of(Complex, c2) end + + bug3656 = '[ruby-core:31622]' + assert_raise(TypeError, bug3656) { + Complex(1,2).marshal_load(0) + } end def test_parse Index: test/ruby/test_rational.rb =================================================================== --- test/ruby/test_rational.rb (revision 28868) +++ test/ruby/test_rational.rb (revision 28869) @@ -797,6 +797,11 @@ assert_raise(ZeroDivisionError){ Marshal.load("\x04\bU:\rRational[\ai\x06i\x05") } + + bug3656 = '[ruby-core:31622]' + assert_raise(TypeError, bug3656) { + Rational(1,2).marshal_load(0) + } end def test_parse Index: rational.c =================================================================== --- rational.c (revision 28868) +++ rational.c (revision 28869) @@ -1602,6 +1602,7 @@ nurat_marshal_load(VALUE self, VALUE a) { get_dat1(self); + Check_Type(a, T_ARRAY); dat->num = RARRAY_PTR(a)[0]; dat->den = RARRAY_PTR(a)[1]; rb_copy_generic_ivar(self, a); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/