mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix error handling for mrb_generate_code().
The return value of mrb_generate_code() must be null-checked before referencing.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user