diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-08-19 20:11:59 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-08-19 20:11:59 +0900 |
| commit | c7fda2232b690f5e68a5d1f72e9dc8cd21682703 (patch) | |
| tree | 44cd2e273c378e37ef6f0535e2a22ec441ae59fc | |
| parent | f62dc56ba2f9401479aeaf333cfdb7ba0909c361 (diff) | |
| parent | e035508efd545dabfad0a1b339dbcd4aacea4604 (diff) | |
| download | mruby-c7fda2232b690f5e68a5d1f72e9dc8cd21682703.tar.gz mruby-c7fda2232b690f5e68a5d1f72e9dc8cd21682703.zip | |
Merge pull request #2541 from cubicdaiya/issues/codegen_error_handling
Fix error handling for mrb_generate_code().
| -rw-r--r-- | mrbgems/mruby-eval/src/eval.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mrbgems/mruby-eval/src/eval.c b/mrbgems/mruby-eval/src/eval.c index 56f4877cc..738d64709 100644 --- a/mrbgems/mruby-eval/src/eval.c +++ b/mrbgems/mruby-eval/src/eval.c @@ -132,6 +132,12 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, cha } proc = mrb_generate_code(mrb, p); + if (proc == NULL) { + /* codegen error */ + mrb_parser_free(p); + mrbc_context_free(mrb, cxt); + mrb_raise(mrb, E_SCRIPT_ERROR, "codegen error"); + } if (mrb->c->ci[-1].proc->target_class) { proc->target_class = mrb->c->ci[-1].proc->target_class; } @@ -146,11 +152,6 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, cha mrb_parser_free(p); mrbc_context_free(mrb, cxt); - if (proc == NULL) { - /* codegen error */ - mrb_raise(mrb, E_SCRIPT_ERROR, "codegen error"); - } - return proc; } |
