`ecall()` should preserve stack address referenced from ci[1].

OP_RETURN accesses ci[1]->stackent that might be broken; fix #3442
parent 0b143898
...@@ -281,6 +281,7 @@ ecall(mrb_state *mrb, int i) ...@@ -281,6 +281,7 @@ ecall(mrb_state *mrb, int i)
mrb_value *self = mrb->c->stack; mrb_value *self = mrb->c->stack;
struct RObject *exc; struct RObject *exc;
int cioff; int cioff;
mrb_value *nstk;
if (i<0) return; if (i<0) return;
p = mrb->c->ensure[i]; p = mrb->c->ensure[i];
...@@ -289,6 +290,7 @@ ecall(mrb_state *mrb, int i) ...@@ -289,6 +290,7 @@ ecall(mrb_state *mrb, int i)
mrb->c->ci->eidx = i; mrb->c->ci->eidx = i;
cioff = mrb->c->ci - mrb->c->cibase; cioff = mrb->c->ci - mrb->c->cibase;
ci = cipush(mrb); ci = cipush(mrb);
nstk = ci->stackent;
ci->stackent = mrb->c->stack; ci->stackent = mrb->c->stack;
ci->mid = ci[-1].mid; ci->mid = ci[-1].mid;
ci->acc = CI_ACC_SKIP; ci->acc = CI_ACC_SKIP;
...@@ -300,6 +302,7 @@ ecall(mrb_state *mrb, int i) ...@@ -300,6 +302,7 @@ ecall(mrb_state *mrb, int i)
exc = mrb->exc; mrb->exc = 0; exc = mrb->exc; mrb->exc = 0;
mrb_run(mrb, p, *self); mrb_run(mrb, p, *self);
mrb->c->ensure[i] = NULL; mrb->c->ensure[i] = NULL;
ci->stackent = nstk;
mrb->c->ci = mrb->c->cibase + cioff; mrb->c->ci = mrb->c->cibase + cioff;
if (!mrb->exc) mrb->exc = exc; if (!mrb->exc) mrb->exc = 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