diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-01-25 12:30:10 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-01-25 12:30:10 +0900 |
| commit | d895861a3084db3d979ba8dfbfa4af8df5e1a42f (patch) | |
| tree | 8b79b1ed4556b395935517f619d2563e00115dcd /src/error.c | |
| parent | 0e93f1ff1263f9d0cabe3f8083ca7adad9b9e556 (diff) | |
| download | mruby-d895861a3084db3d979ba8dfbfa4af8df5e1a42f.tar.gz mruby-d895861a3084db3d979ba8dfbfa4af8df5e1a42f.zip | |
Check `arena_idx` before accessing; fix #3934
Diffstat (limited to 'src/error.c')
| -rw-r--r-- | src/error.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/error.c b/src/error.c index 1b24f3065..5445b51bf 100644 --- a/src/error.c +++ b/src/error.c @@ -229,7 +229,8 @@ mrb_exc_set(mrb_state *mrb, mrb_value exc) } else { mrb->exc = mrb_obj_ptr(exc); - if ((struct RBasic*)mrb->exc == mrb->gc.arena[mrb->gc.arena_idx-1]) { + if (mrb->gc.arena_idx > 0 && + (struct RBasic*)mrb->exc == mrb->gc.arena[mrb->gc.arena_idx-1]) { mrb->gc.arena_idx--; } if (!mrb->gc.out_of_memory) { |
