From 4cf9b2fd1cc51bcb968a343c2e873b3777585752 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 21 Mar 2015 11:20:44 +0900 Subject: execute ensure clause only when skipping call frame; fix #2726 --- src/vm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/vm.c b/src/vm.c index 390fdddea..31b80c972 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1474,12 +1474,7 @@ RETRY_TRY_BLOCK: 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; @@ -1495,6 +1490,12 @@ RETRY_TRY_BLOCK: } 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; -- cgit v1.2.3