diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-05-28 18:43:20 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-05-28 18:53:27 +0900 |
| commit | d5cca2bdb2a0352e3253cf3ba2a79157dde5f163 (patch) | |
| tree | cace3c86b7a832dec98236eed86f3a896394dd00 /src | |
| parent | ebbb4fd7fb93b9279d65189b086cbc111f97a427 (diff) | |
| download | mruby-d5cca2bdb2a0352e3253cf3ba2a79157dde5f163.tar.gz mruby-d5cca2bdb2a0352e3253cf3ba2a79157dde5f163.zip | |
Check `c->eidx` before decrement in `ecall()`; close #4977
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -336,10 +336,12 @@ ecall(mrb_state *mrb) struct REnv *env; ptrdiff_t cioff; int ai = mrb_gc_arena_save(mrb); - uint16_t i = --c->eidx; + uint16_t i; int nregs; - if (i<0) return; + if (c->eidx == 0) return; + i = --c->eidx; + /* restrict total call depth of ecall() */ if (++mrb->ecall_nest > MRB_ECALL_DEPTH_MAX) { mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err)); |
