Fix codegen issue causing misaligned register

Reported by https://hackerone.com/haquaman
parent a630c4f4
...@@ -2024,6 +2024,7 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2024,6 +2024,7 @@ codegen(codegen_scope *s, node *tree, int val)
} }
genop(s, MKOP_sBx(OP_JMP, s->loop->pc2 - s->pc)); genop(s, MKOP_sBx(OP_JMP, s->loop->pc2 - s->pc));
} }
if (val) push();
break; break;
case NODE_RETRY: case NODE_RETRY:
...@@ -2058,6 +2059,7 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2058,6 +2059,7 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_sBx(OP_JMP, lp->pc1 - s->pc)); genop(s, MKOP_sBx(OP_JMP, lp->pc1 - s->pc));
} }
} }
if (val) push();
} }
break; break;
......
##
# Codegen tests
assert('codegen absorbs arguments to redo and retry if they are the argument of a call') do
assert_nothing_raised do
a=*"1", case nil
when 1
redo |
1
end
end
assert_nothing_raised do
a=*"1", case nil
when 1
retry |
1
end
end
end
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