From 53a7549e1c0dd9a189ac40804b2f5f3e600c9e76 Mon Sep 17 00:00:00 2001 From: Tatsuhiko Kubo Date: Wed, 20 Aug 2014 05:15:21 +0900 Subject: Fix error handling for mrb_open_allocf(). When DISABLE_GEMS is not defined and a return value of mrb_open_core() is NULL, mrb_open_allocf() may cause SEGV. --- src/state.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/state.c b/src/state.c index 9c16524f2..8d6993b6f 100644 --- a/src/state.c +++ b/src/state.c @@ -110,6 +110,10 @@ mrb_open_allocf(mrb_allocf f, void *ud) { mrb_state *mrb = mrb_open_core(f, ud); + if (mrb == NULL) { + return NULL; + } + #ifndef DISABLE_GEMS mrb_init_mrbgems(mrb); mrb_gc_arena_restore(mrb, 0); -- cgit v1.2.3