From ab99e2c293167935033016750c010047a2aba76a Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 1 Sep 2017 06:50:24 +0900 Subject: Avoid copying over initialized procs using `initialize_copy`; fix #3803 It may be better to raise exceptions, but CRuby doesn't. --- src/proc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/proc.c b/src/proc.c index 96b080f9e..10a2c4f33 100644 --- a/src/proc.c +++ b/src/proc.c @@ -139,6 +139,10 @@ mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx) void mrb_proc_copy(struct RProc *a, struct RProc *b) { + if (a->body.irep) { + /* already initialized proc */ + return; + } a->flags = b->flags; a->body = b->body; if (!MRB_PROC_CFUNC_P(a) && a->body.irep) { -- cgit v1.2.3