Skip to content

Commit

Permalink
execute ensure clause only when skipping call frame; fix #2726
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 21, 2015
1 parent 0e218f5 commit 4cf9b2f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1474,12 +1474,7 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
mrb->jmp = prev_jmp;
MRB_THROW(prev_jmp);
}
if (ci > mrb->c->cibase) {
while (eidx > ci[-1].eidx) {
ecall(mrb, --eidx);
}
}
else if (ci == mrb->c->cibase) {
if (ci == mrb->c->cibase) {
if (ci->ridx == 0) {
if (mrb->c == mrb->root_c) {
regs = mrb->c->stack = mrb->c->stbase;
Expand All @@ -1495,6 +1490,12 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
}
break;
}
/* call ensure only when we skip this callinfo */
if (ci[0].ridx == ci[-1].ridx) {
while (eidx > ci[-1].eidx) {
ecall(mrb, --eidx);
}
}
}
L_RESCUE:
if (ci->ridx == 0) goto L_STOP;
Expand Down

0 comments on commit 4cf9b2f

Please sign in to comment.