diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-29 20:25:55 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-29 20:25:55 +0900 |
| commit | 5f7cdecdc9cf15293403955997e6e57ec94321a0 (patch) | |
| tree | 8b1afc9489fd5d19de5537bff7690eced7e2882e | |
| parent | b746a0f0d273cb4b6f16ffad86ca7ea64d002ad2 (diff) | |
| download | mruby-5f7cdecdc9cf15293403955997e6e57ec94321a0.tar.gz mruby-5f7cdecdc9cf15293403955997e6e57ec94321a0.zip | |
Clear `c->prev` on fiber termination.
| -rw-r--r-- | src/vm.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1968,6 +1968,8 @@ RETRY_TRY_BLOCK: case OP_R_NORMAL: NORMAL_RETURN: if (ci == mrb->c->cibase) { + struct mrb_context *c; + if (!mrb->c->prev) { /* toplevel return */ localjump_error(mrb, LOCALJUMP_ERROR_RETURN); goto L_RAISE; @@ -1981,8 +1983,10 @@ RETRY_TRY_BLOCK: ecall(mrb); } /* automatic yield at the end */ - mrb->c->status = MRB_FIBER_TERMINATED; - mrb->c = mrb->c->prev; + c = mrb->c; + c->status = MRB_FIBER_TERMINATED; + mrb->c = c->prev; + c->prev = NULL; mrb->c->status = MRB_FIBER_RUNNING; ci = mrb->c->ci; } |
