summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-28 09:45:49 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-08-28 10:06:04 +0900
commit15d48efa4bf6a6b999dab99720fb9fe3c4a06ef0 (patch)
treea454a4bf8acde664556358d3141bb3f43da8a7e4 /src
parentfd927d786eee1ecde94d9a791036c07543340e7b (diff)
downloadmruby-15d48efa4bf6a6b999dab99720fb9fe3c4a06ef0.tar.gz
mruby-15d48efa4bf6a6b999dab99720fb9fe3c4a06ef0.zip
Clear `irep->outer` when no `Proc` reference the `irep`; fix #3793
Diffstat (limited to 'src')
-rw-r--r--src/gc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gc.c b/src/gc.c
index dd63395bd..49cc137f5 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -815,7 +815,11 @@ obj_free(mrb_state *mrb, struct RBasic *obj, int end)
struct RProc *p = (struct RProc*)obj;
if (!MRB_PROC_CFUNC_P(p) && p->body.irep) {
+ int refcnt = p->body.irep->refcnt;
mrb_irep_decref(mrb, p->body.irep);
+ if (refcnt == 2) { /* reference only from irep */
+ p->body.irep->outer = NULL;
+ }
}
}
break;