Commit ae2d4981 authored by Tatsuhiko Kubo's avatar Tatsuhiko Kubo

Fix allocation-error-handlings for scope_new().

parent f6f31a8e
......@@ -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) {
......
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