Commit 20e9d53f authored by Tomoyuki Sahara's avatar Tomoyuki Sahara

fix out-of-bound access on compiling empty blocks.

parent eb080397
......@@ -511,8 +511,9 @@ for_body(codegen_scope *s, node *tree)
}
codegen(s, tree->cdr->cdr->car, VAL);
pop();
if (s->pc > 0) {
c = s->iseq[s->pc-1];
if (GET_OPCODE(c) != OP_RETURN || GETARG_B(c) != OP_R_NORMAL || s->pc == s->lastlabel) {
if (GET_OPCODE(c) != OP_RETURN || GETARG_B(c) != OP_R_NORMAL || s->pc == s->lastlabel)
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
}
loop_pop(s, NOVAL);
......@@ -593,6 +594,7 @@ lambda_body(codegen_scope *s, node *tree, int blk)
}
codegen(s, tree->cdr->car, VAL);
pop();
if (s->pc > 0) {
c = s->iseq[s->pc-1];
if (GET_OPCODE(c) != OP_RETURN || GETARG_B(c) != OP_R_NORMAL || s->pc == s->lastlabel) {
if (s->nregs == 0) {
......@@ -603,6 +605,7 @@ lambda_body(codegen_scope *s, node *tree, int blk)
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
}
}
}
if (blk) {
loop_pop(s, NOVAL);
}
......
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