Fix segfault caused by empty condition in ternary

Reported by https://hackerone.com/jpenalbae
This commit is contained in:
Bouke van der Bijl
2016-11-14 17:28:18 -05:00
parent a630c4f413
commit 71641bbf73
2 changed files with 10 additions and 0 deletions
+4
View File
@@ -1362,6 +1362,10 @@ codegen(codegen_scope *s, node *tree, int val)
int pos1, pos2;
node *e = tree->cdr->cdr->car;
if (!tree->car) {
codegen(s, e, val);
return;
}
switch ((intptr_t)tree->car->car) {
case NODE_TRUE:
case NODE_INT:
+6
View File
@@ -0,0 +1,6 @@
##
# Codegen tests
assert('empty condition in ternary expression parses correctly') do
assert_equal () ? 1 : 2, 2
end