Permalink
Browse files

Fix segfault caused by empty condition in ternary

  • Loading branch information...
bouk committed Nov 14, 2016
1 parent a630c4f commit 71641bbf732ab8cbadf8a07e20b2a939b0e3b82b
Showing with 10 additions and 0 deletions.
  1. +4 −0 mrbgems/mruby-compiler/core/codegen.c
  2. +6 −0 test/t/codegen.rb
@@ -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:
View
@@ -0,0 +1,6 @@
##
# Codegen tests
assert('empty condition in ternary expression parses correctly') do
assert_equal () ? 1 : 2, 2
end

0 comments on commit 71641bb

Please sign in to comment.