Permalink
Browse files

The ensure clause should keep its ci after its execution; fix #3406

This issue was reported by https://hackerone.com/ston3
  • Loading branch information...
matz committed Jan 23, 2017
1 parent 324887d commit ffb5e5ab08624c899de03b5347966eb3e070dce5
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/vm.c
View
@@ -280,12 +280,14 @@ ecall(mrb_state *mrb, int i)
mrb_callinfo *ci;
mrb_value *self = mrb->c->stack;
struct RObject *exc;
int cioff;
if (i<0) return;
p = mrb->c->ensure[i];
if (!p) return;
if (mrb->c->ci->eidx > i)
mrb->c->ci->eidx = i;
cioff = mrb->c->ci - mrb->c->cibase;
ci = cipush(mrb);
ci->stackent = mrb->c->stack;
ci->mid = ci[-1].mid;
@@ -298,6 +300,7 @@ ecall(mrb_state *mrb, int i)
exc = mrb->exc; mrb->exc = 0;
mrb_run(mrb, p, *self);
mrb->c->ensure[i] = NULL;
mrb->c->ci = mrb->c->cibase + cioff;
if (!mrb->exc) mrb->exc = exc;
}

0 comments on commit ffb5e5a

Please sign in to comment.