summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/error.c3
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) {