diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-04-03 18:38:49 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-04-03 18:38:49 +0900 |
| commit | b8461c86817fd2f766746e61e9f93362955a3474 (patch) | |
| tree | 25d133ce2e0ba9e17492ad895b65f71edf6a076b /src/vm.c | |
| parent | 6a992a2579562bfeacd6f1f1ef14a98bff59fff0 (diff) | |
| download | mruby-b8461c86817fd2f766746e61e9f93362955a3474.tar.gz mruby-b8461c86817fd2f766746e61e9f93362955a3474.zip | |
Protect ensure clause lambdas from GC; fix #3491
Diffstat (limited to 'src/vm.c')
| -rw-r--r-- | src/vm.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -296,6 +296,7 @@ ecall(mrb_state *mrb, int i) } p = mrb->c->ensure[i]; if (!p) return; + mrb->c->ensure[i] = NULL; if (mrb->c->ci->eidx > i) mrb->c->ci->eidx = i; cioff = mrb->c->ci - mrb->c->cibase; @@ -310,7 +311,6 @@ ecall(mrb_state *mrb, int i) mrb->c->stack = mrb->c->stack + ci[-1].nregs; 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; } @@ -1148,6 +1148,7 @@ RETRY_TRY_BLOCK: mrb->c->ensure = (struct RProc **)mrb_realloc(mrb, mrb->c->ensure, sizeof(struct RProc*) * mrb->c->esize); } mrb->c->ensure[mrb->c->ci->eidx++] = p; + mrb->c->ensure[mrb->c->ci->eidx] = NULL; ARENA_RESTORE(mrb, ai); NEXT; } |
