Skip to content

Commit

Permalink
ecall() should preserve stack address referenced from ci[1].
Browse files Browse the repository at this point in the history
OP_RETURN accesses ci[1]->stackent that might be broken; fix #3442
  • Loading branch information
matz committed Feb 11, 2017
1 parent 0b14389 commit 642ab8e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ ecall(mrb_state *mrb, int i)
mrb_value *self = mrb->c->stack;
struct RObject *exc;
int cioff;
mrb_value *nstk;

if (i<0) return;
p = mrb->c->ensure[i];
Expand All @@ -289,6 +290,7 @@ ecall(mrb_state *mrb, int i)
mrb->c->ci->eidx = i;
cioff = mrb->c->ci - mrb->c->cibase;
ci = cipush(mrb);
nstk = ci->stackent;
ci->stackent = mrb->c->stack;
ci->mid = ci[-1].mid;
ci->acc = CI_ACC_SKIP;
Expand All @@ -300,6 +302,7 @@ ecall(mrb_state *mrb, int i)
exc = mrb->exc; mrb->exc = 0;
mrb_run(mrb, p, *self);
mrb->c->ensure[i] = NULL;
ci->stackent = nstk;
mrb->c->ci = mrb->c->cibase + cioff;
if (!mrb->exc) mrb->exc = exc;
}
Expand Down

0 comments on commit 642ab8e

Please sign in to comment.