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:
Yukihiro "Matz" Matsumoto
2016-12-10 15:52:41 +09:00
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -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:
{
+10
View File
@@ -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