Fix segfault in mrb_proc_copy.

This commit is contained in:
Clayton Smith
2016-11-24 15:51:25 -05:00
parent 2cca9d3688
commit 1ff4b3f800
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -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;
+16
View File
@@ -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