mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #3324 from bouk/mruby/bouk-negate
Don't generate code for NODE_NEGATE if the result isn't used Reported by https://hackerone.com/haquaman
This commit is contained in:
@@ -2221,6 +2221,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:
|
||||
{
|
||||
|
||||
@@ -81,3 +81,13 @@ assert('next in normal loop with 127 arguments') do
|
||||
end
|
||||
end
|
||||
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