mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix allocation-error-handlings for scope_new().
This commit is contained in:
@@ -85,6 +85,7 @@ static void gen_assignment(codegen_scope *s, node *node, int sp, int val);
|
||||
static void gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val);
|
||||
|
||||
static void codegen(codegen_scope *s, node *tree, int val);
|
||||
static void raise_error(codegen_scope *s, const char *msg);
|
||||
|
||||
static void
|
||||
codegen_error(codegen_scope *s, const char *message)
|
||||
@@ -552,6 +553,10 @@ for_body(codegen_scope *s, node *tree)
|
||||
codegen(s, tree->cdr->car, VAL);
|
||||
/* generate loop-block */
|
||||
s = scope_new(s->mrb, s, NULL);
|
||||
if (s == NULL) {
|
||||
raise_error(s, "unexpected scope");
|
||||
}
|
||||
|
||||
push(); /* push for a block parameter */
|
||||
|
||||
lp = loop_push(s, LOOP_FOR);
|
||||
@@ -589,6 +594,10 @@ lambda_body(codegen_scope *s, node *tree, int blk)
|
||||
mrb_code c;
|
||||
codegen_scope *parent = s;
|
||||
s = scope_new(s->mrb, s, tree->car);
|
||||
if (s == NULL) {
|
||||
raise_error(s, "unexpected scope");
|
||||
}
|
||||
|
||||
s->mscope = !blk;
|
||||
|
||||
if (blk) {
|
||||
@@ -674,6 +683,9 @@ static int
|
||||
scope_body(codegen_scope *s, node *tree, int val)
|
||||
{
|
||||
codegen_scope *scope = scope_new(s->mrb, s, tree->car);
|
||||
if (scope == NULL) {
|
||||
raise_error(s, "unexpected scope");
|
||||
}
|
||||
|
||||
codegen(scope, tree->cdr, VAL);
|
||||
if (!s->iseq) {
|
||||
|
||||
Reference in New Issue
Block a user