summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-09-07 07:37:19 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-09-07 07:37:19 +0900
commit674d841ead126e41471bd53a490d0d20aa0cff53 (patch)
tree20556b4d833a241a887d03e6f27b53aeb28c8ffe
parent711f06a562117c63b5b7b04f79d3c4a6b076b098 (diff)
downloadmruby-674d841ead126e41471bd53a490d0d20aa0cff53.tar.gz
mruby-674d841ead126e41471bd53a490d0d20aa0cff53.zip
eval.c: if the parser raises an exception without an error message
`eval` would have crashed in formatting.
-rw-r--r--mrbgems/mruby-eval/src/eval.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mrbgems/mruby-eval/src/eval.c b/mrbgems/mruby-eval/src/eval.c
index a3c421f45..c21284bdd 100644
--- a/mrbgems/mruby-eval/src/eval.c
+++ b/mrbgems/mruby-eval/src/eval.c
@@ -81,6 +81,11 @@ create_proc_from_string(mrb_state *mrb, const char *s, mrb_int len, mrb_value bi
/* parse error */
mrb_value str;
+ mrbc_context_free(mrb, cxt);
+ if (!p->error_buffer[0].message) {
+ mrb_parser_free(p);
+ mrb_raise(mrb, E_SYNTAX_ERROR, "compile error");
+ }
if (file) {
str = mrb_format(mrb, "file %s line %d: %s",
file,
@@ -93,7 +98,6 @@ create_proc_from_string(mrb_state *mrb, const char *s, mrb_int len, mrb_value bi
p->error_buffer[0].message);
}
mrb_parser_free(p);
- mrbc_context_free(mrb, cxt);
mrb_exc_raise(mrb, mrb_exc_new_str(mrb, E_SYNTAX_ERROR, str));
}