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

marshal.c: revert r57631 partially

* marshal.c (rb_marshal_dump_limited): do not free dump_arg, which
  may be dereferenced in check_dump_arg due to continuation, and
  get rid of dangling pointers.

* marshal.c (rb_marshal_load_with_proc): ditto for load_arg.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-02-15 08:38:01 +00:00
parent cd89148199
commit d9ae8c0bc8
2 changed files with 7 additions and 4 deletions

View file

@ -1053,8 +1053,8 @@ rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
rb_io_write(arg->dest, arg->str); rb_io_write(arg->dest, arg->str);
rb_str_resize(arg->str, 0); rb_str_resize(arg->str, 0);
} }
free_dump_arg(arg); clear_dump_arg(arg);
rb_gc_force_recycle(wrapper); RB_GC_GUARD(wrapper);
return port; return port;
} }
@ -2084,8 +2084,8 @@ rb_marshal_load_with_proc(VALUE port, VALUE proc)
if (!NIL_P(proc)) arg->proc = proc; if (!NIL_P(proc)) arg->proc = proc;
v = r_object(arg); v = r_object(arg);
free_load_arg(arg); clear_load_arg(arg);
rb_gc_force_recycle(wrapper); RB_GC_GUARD(wrapper);
return v; return v;
} }

View file

@ -644,6 +644,9 @@ class TestMarshal < Test::Unit::TestCase
c = Bug9523.new c = Bug9523.new
assert_raise_with_message(RuntimeError, /Marshal\.dump reentered at marshal_dump/) do assert_raise_with_message(RuntimeError, /Marshal\.dump reentered at marshal_dump/) do
Marshal.dump(c) Marshal.dump(c)
GC.start
1000.times {"x"*1000}
GC.start
c.cc.call c.cc.call
end end
end end