The stack shift width should be determined by `p->upper`; fix #3864

And check required register number from `ci->proc` as well.
The fixes for #3859 and #3862 were incomplete.
parent 86ef9a28
......@@ -326,7 +326,10 @@ ecall(mrb_state *mrb)
if (!p) return;
mrb_assert(!MRB_PROC_CFUNC_P(p));
c->ensure[i] = NULL;
nregs = ci->proc->body.irep->nregs;
nregs = p->upper->body.irep->nregs;
if (ci->proc->body.irep->nregs > nregs) {
nregs = ci->proc->body.irep->nregs;
}
cioff = ci - c->cibase;
ci = cipush(mrb);
ci->stackent = mrb->c->stack;
......@@ -336,9 +339,9 @@ ecall(mrb_state *mrb)
ci->proc = p;
ci->nregs = p->body.irep->nregs;
ci->target_class = MRB_PROC_TARGET_CLASS(p);
c->stack += nregs;
env = MRB_PROC_ENV(p);
mrb_assert(env);
c->stack += nregs;
exc = mrb->exc; mrb->exc = 0;
if (exc) {
mrb_gc_protect(mrb, mrb_obj_value(exc));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment