mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Don't generate code for NODE_NEGATE if the result isn't used
Reported by https://hackerone.com/haquaman
This commit is contained in:
@@ -2223,6 +2223,10 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
{
|
||||
nt = (intptr_t)tree->car;
|
||||
tree = tree->cdr;
|
||||
if (!val) {
|
||||
codegen(s, tree, NOVAL);
|
||||
break;
|
||||
}
|
||||
switch (nt) {
|
||||
case NODE_FLOAT:
|
||||
{
|
||||
|
||||
@@ -63,3 +63,13 @@ assert('splat in case splat') do
|
||||
|
||||
assert_equal [1], a
|
||||
end
|
||||
|
||||
assert('negate literal register alignment') do
|
||||
a = *case
|
||||
when 0
|
||||
-0.0
|
||||
2
|
||||
end
|
||||
|
||||
assert_equal [2], a
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user