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;