Fix segfault in mrb_proc_copy.

parent 2cca9d36
......@@ -140,7 +140,7 @@ mrb_proc_copy(struct RProc *a, struct RProc *b)
{
a->flags = b->flags;
a->body = b->body;
if (!MRB_PROC_CFUNC_P(a)) {
if (!MRB_PROC_CFUNC_P(a) && a->body.irep) {
a->body.irep->refcnt++;
}
a->target_class = b->target_class;
......
......@@ -163,3 +163,19 @@ assert('&obj call to_proc if defined') do
assert_raise(TypeError){ mock(&(Object.new)) }
end
assert('initialize_copy works when initialize is removed') do
begin
Proc.alias_method(:old_initialize, :initialize)
Proc.remove_method(:initialize)
a = Proc.new {}
b = Proc.new {}
assert_nothing_raised do
a.initialize_copy(b)
end
ensure
Proc.alias_method(:initialize, :old_initialize)
Proc.remove_method(:old_initialize)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment