1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* marshal.c (w_object): reverted r26007. [ruby-dev:39845]

* test/test_delegate.rb (test_marshal): moved from test_marshal.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-12-07 05:11:10 +00:00
parent 1c2ef61035
commit 1d10aa8bfc
4 changed files with 25 additions and 13 deletions

View file

@ -1,3 +1,9 @@
Mon Dec 7 14:11:08 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (w_object): reverted r26007. [ruby-dev:39845]
* test/test_delegate.rb (test_marshal): moved from test_marshal.rb.
Mon Dec 7 13:05:59 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* string.c (rb_str_justify): CVE-2009-4124.

View file

@ -643,23 +643,14 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
if (rb_respond_to(obj, s_mdump)) {
volatile VALUE v;
int hasiv2 = 0;
st_add_direct(arg->data, obj, arg->data->num_entries);
v = rb_funcall(obj, s_mdump, 0, 0);
check_dump_arg(arg, s_mdump);
if (!hasiv && (hasiv2 = rb_ivar_count(obj) > 0)) {
w_byte(TYPE_IVAR, arg);
}
w_class(TYPE_USRMARSHAL, obj, arg, FALSE);
w_object(v, arg, limit);
if (hasiv) {
w_ivar(obj, ivtbl, &c_arg);
}
else if (hasiv2) {
w_objivar(obj, &c_arg);
}
if (hasiv) w_ivar(obj, ivtbl, &c_arg);
return;
}
if (rb_respond_to(obj, s_dump)) {

View file

@ -323,11 +323,10 @@ class TestMarshal < Test::Unit::TestCase
end
end
def test_marshal_dump
bug1744 = '[ruby-core:24211]'
c = C5.new("bar")
s = Marshal.dump(c)
d = Marshal.load(s)
assert_equal("foo", d.instance_variable_get(:@foo), bug1744)
assert_equal("bar", d.instance_variable_get(:@x), bug1744)
assert_equal("foo", d.instance_variable_get(:@foo))
assert_equal(false, d.instance_variable_defined?(:@x))
end
end

View file

@ -51,4 +51,20 @@ class TestDelegateClass < Test::Unit::TestCase
assert_equal(:m, SimpleDelegator.new(Foo.new).m)
assert_equal(:m, Bar.new(Foo.new).m)
end
class IV < DelegateClass(Integer)
attr_accessor :var
def initialize
@var = 1
end
end
def test_marshal
bug1744 = '[ruby-core:24211]'
c = IV.new
assert_equal(1, c.var)
d = Marshal.load(Marshal.dump(c))
assert_equal(1, d.var, bug1744)
end
end