mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
The ensure clause should keep its ci after its execution; fix #3406
This issue was reported by https://hackerone.com/ston3
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user