summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-08-20 09:25:10 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-08-20 09:25:10 +0900
commit28cf769a6e699bdc85a868f05cf1ea9382a56d97 (patch)
tree6bd1025c303e8016477caa75e74f54e57572c121
parentd49f8517a6d2350eb1ed2642749f3994a9a2d056 (diff)
parenteffc44f265c19d25545e01b94831631c3a5bef5f (diff)
downloadmruby-28cf769a6e699bdc85a868f05cf1ea9382a56d97.tar.gz
mruby-28cf769a6e699bdc85a868f05cf1ea9382a56d97.zip
Merge pull request #2544 from cubicdaiya/issues/mrb_open_core_error_handling
Fix error handlings for mrb_open_core().
-rw-r--r--tasks/mrbgem_spec.rake1
-rw-r--r--tasks/mrbgems_test.rake4
-rw-r--r--test/init_mrbtest.c4
3 files changed, 9 insertions, 0 deletions
diff --git a/tasks/mrbgem_spec.rake b/tasks/mrbgem_spec.rake
index 1d97e2bbf..95e1c5f02 100644
--- a/tasks/mrbgem_spec.rake
+++ b/tasks/mrbgem_spec.rake
@@ -183,6 +183,7 @@ module MRuby
def print_gem_test_header(f)
print_gem_comment(f)
+ f.puts %Q[#include <stdio.h>]
f.puts %Q[#include <stdlib.h>]
f.puts %Q[#include "mruby.h"]
f.puts %Q[#include "mruby/irep.h"]
diff --git a/tasks/mrbgems_test.rake b/tasks/mrbgems_test.rake
index f3496dc8d..016379197 100644
--- a/tasks/mrbgems_test.rake
+++ b/tasks/mrbgems_test.rake
@@ -47,6 +47,10 @@ MRuby.each_target do
g.test_rbfiles.count.times do |i|
f.puts %Q[ ai = mrb_gc_arena_save(mrb);]
f.puts %Q[ mrb2 = mrb_open_core(mrb_default_allocf, NULL);]
+ f.puts %Q[ if (mrb2 == NULL) {]
+ f.puts %Q[ fprintf(stderr, "Invalid mrb_state, exiting \%s", __FUNCTION__);]
+ f.puts %Q[ exit(EXIT_FAILURE);]
+ f.puts %Q[ }]
dep_list.each do |d|
f.puts %Q[ GENERATED_TMP_mrb_#{d.funcname}_gem_init(mrb2);]
f.puts %Q[ mrb_state_atexit(mrb2, GENERATED_TMP_mrb_#{d.funcname}_gem_final);]
diff --git a/test/init_mrbtest.c b/test/init_mrbtest.c
index 2a32f4930..1e2ba92bd 100644
--- a/test/init_mrbtest.c
+++ b/test/init_mrbtest.c
@@ -18,6 +18,10 @@ mrb_init_mrbtest(mrb_state *mrb)
mrb_load_irep(mrb, mrbtest_assert_irep);
core_test = mrb_open_core(mrb_default_allocf, NULL);
+ if (core_test == NULL) {
+ fprintf(stderr, "Invalid mrb_state, exiting %s", __FUNCTION__);
+ exit(EXIT_FAILURE);
+ }
mrb_init_test_driver(core_test, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));
mrb_load_irep(core_test, mrbtest_assert_irep);
mrb_load_irep(core_test, mrbtest_irep);