summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-03 01:26:41 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-03 01:26:41 +0000
commit89ae71d72157aa8800443741ff328199d7ba59e5 (patch)
treee6fe98c67139e01ca14d43237aa509fe7a7af6b9
parent82cd48d7ee799ff1cd37c0ea0be2ab0d0aea9a2e (diff)
* complex.c (nucomp_marshal_load): [ruby-core:45394]
* rational.c (nurat_marshal_load): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--complex.c4
-rw-r--r--rational.c4
-rw-r--r--test/ruby/test_complex.rb5
-rw-r--r--test/ruby/test_rational.rb5
5 files changed, 23 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e6549cb4ad..4f1ada5297 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Jun 3 10:23:32 2012 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_marshal_load): [ruby-core:45394]
+ * rational.c (nurat_marshal_load): ditto.
+
Sun Jun 3 03:15:46 2012 NARUSE, Yui <naruse@ruby-lang.org>
* regparse.c (onig_number_of_names): suppress a warning.
diff --git a/complex.c b/complex.c
index a6538606f6..1aae3b6ca8 100644
--- a/complex.c
+++ b/complex.c
@@ -1259,6 +1259,10 @@ static VALUE
nucomp_marshal_load(VALUE self, VALUE a)
{
get_dat1(self);
+
+ rb_check_frozen(self);
+ rb_check_trusted(self);
+
Check_Type(a, T_ARRAY);
if (RARRAY_LEN(a) != 2)
rb_raise(rb_eArgError, "marshaled complex must have an array whose length is 2 but %ld", RARRAY_LEN(a));
diff --git a/rational.c b/rational.c
index 8d0e8306f5..c4469c8092 100644
--- a/rational.c
+++ b/rational.c
@@ -1605,6 +1605,10 @@ static VALUE
nurat_marshal_load(VALUE self, VALUE a)
{
get_dat1(self);
+
+ rb_check_frozen(self);
+ rb_check_trusted(self);
+
Check_Type(a, T_ARRAY);
if (RARRAY_LEN(a) != 2)
rb_raise(rb_eArgError, "marshaled rational must have an array whose length is 2 but %ld", RARRAY_LEN(a));
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index c6c6ef9882..aa6d6a77fe 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -661,6 +661,11 @@ class Complex_Test < Test::Unit::TestCase
assert_raise(TypeError, bug3656) {
Complex(1,2).marshal_load(0)
}
+
+ c = Complex(1,2)
+ c.freeze
+ assert(c.frozen?)
+ assert_raise(RuntimeError){c.marshal_load([2,3])}
end
def test_parse
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 70aab03c38..e1aafb5a0a 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -831,6 +831,11 @@ class Rational_Test < Test::Unit::TestCase
assert_raise(TypeError, bug3656) {
Rational(1,2).marshal_load(0)
}
+
+ c = Rational(1,2)
+ c.freeze
+ assert(c.frozen?)
+ assert_raise(RuntimeError){c.marshal_load([2,3])}
end
def test_parse