Commit e035508e authored by Tatsuhiko Kubo's avatar Tatsuhiko Kubo

Fix error handling for mrb_generate_code().

The return value of mrb_generate_code()
must be null-checked before referencing.
parent f62dc56b
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment