Unverified Commit 964427f8 authored by Francis Bogsanyi's avatar Francis Bogsanyi Committed by Bouke van der Bijl

Fix unsafe peephole optimization

Reported by https://hackerone.com/dkasak
parent a630c4f4
...@@ -1798,8 +1798,10 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1798,8 +1798,10 @@ codegen(codegen_scope *s, node *tree, int val)
int pos; int pos;
pop(); pop();
if (val && vsp >= 0) { if (val) {
genop(s, MKOP_AB(OP_MOVE, vsp, cursp())); if (vsp >= 0) {
genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
}
pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0)); pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0));
} }
else { else {
......
##
# Codegen tests
assert('peephole optimization does not eliminate move whose result is reused') do
assert_raise LocalJumpError do
def method
yield
end
method(&a &&= 0)
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