Permalink
Browse files

Fix segfault in mrb_proc_copy.

  • Loading branch information...
clayton-shopify committed Nov 24, 2016
1 parent 2cca9d3 commit 1ff4b3f800d369510658b7926a1d6dc9327d0422
Showing with 17 additions and 1 deletion.
  1. +1 −1 src/proc.c
  2. +16 −0 test/t/proc.rb
View
@@ -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;
View
@@ -163,3 +163,19 @@ def obj.to_proc
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

0 comments on commit 1ff4b3f

Please sign in to comment.