From 35bbd6681235af84eb8738511a6fb5697ca10cc2 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 29 Oct 2013 16:39:57 +0900 Subject: [PATCH] fix gc bug: ci->env and env-up are nullable --- src/gc.c | 8 ++++++-- src/vm.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gc.c b/src/gc.c index af3e56fe..92dc16d9 100644 --- a/src/gc.c +++ b/src/gc.c @@ -162,7 +162,9 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) for (i = 0; i < env->num_val; ++i) { gc_mark(pic, env->values[i]); } - gc_mark_object(pic, (struct pic_object *)env->up); + if (env->up) { + gc_mark_object(pic, (struct pic_object *)env->up); + } break; } case PIC_TT_PROC: { @@ -222,7 +224,9 @@ gc_mark_phase(pic_state *pic) /* callinfo */ for (ci = pic->ci; ci != pic->cibase; --ci) { - gc_mark_object(pic, (struct pic_object *)ci->env); + if (ci->env) { + gc_mark_object(pic, (struct pic_object *)ci->env); + } } /* arena */ diff --git a/src/vm.c b/src/vm.c index 4c4c2674..d6685f41 100644 --- a/src/vm.c +++ b/src/vm.c @@ -317,6 +317,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) ci->argc = pc->u.i; ci->pc = pc; ci->fp = pic->sp - pc->u.i; + ci->env = NULL; if (pic_proc_cfunc_p(c)) { v = proc->u.cfunc(pic); pic->sp = ci->fp;