mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #3321 from clayton-shopify/fix-proc-crash-upstream
Fix segfault in mrb_proc_copy.
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user