eval.c: if the parser raises an exception without an error message

`eval` would have crashed in formatting.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-09-07 07:37:19 +09:00
parent 711f06a562
commit 674d841ead
+5 -1
View File
@@ -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));
}