Skip to content

Commit 4e013b0

Browse files
matztsahara
authored andcommitted
execute ensure clause only when skipping call frame; fix mruby#2726
1 parent 23cfc83 commit 4e013b0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/vm.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,18 +1386,19 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
13861386
mrb->jmp = prev_jmp;
13871387
mrb_longjmp(mrb);
13881388
}
1389-
if (ci > mrb->c->cibase) {
1390-
while (eidx > ci[-1].eidx) {
1391-
ecall(mrb, --eidx);
1392-
}
1393-
}
1394-
else if (ci == mrb->c->cibase) {
1389+
if (ci == mrb->c->cibase) {
13951390
if (ci->ridx == 0) {
13961391
regs = mrb->c->stack = mrb->c->stbase;
13971392
goto L_STOP;
13981393
}
13991394
break;
14001395
}
1396+
/* call ensure only when we skip this callinfo */
1397+
if (ci[0].ridx == ci[-1].ridx) {
1398+
while (eidx > ci[-1].eidx) {
1399+
ecall(mrb, --eidx);
1400+
}
1401+
}
14011402
}
14021403
L_RESCUE:
14031404
if (ci->ridx == 0) goto L_STOP;

0 commit comments

Comments
 (0)