Check arena_idx before accessing; fix #3934

This commit is contained in:
Yukihiro "Matz" Matsumoto
2018-01-25 12:30:10 +09:00
parent 0e93f1ff12
commit d895861a30
+2 -1
View File
@@ -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) {