Permalink
Browse files

Fix nested empty heredoc causing segfault

  • Loading branch information...
bouk committed Nov 18, 2016
1 parent a630c4f commit 73e4f069becaf69707b990d658b34155f8973508
Showing with 16 additions and 2 deletions.
  1. +5 −1 mrbgems/mruby-compiler/core/codegen.c
  2. +1 −1 mrbgems/mruby-compiler/core/parse.y
  3. +10 −0 test/t/codegen.rb
@@ -2285,7 +2285,11 @@ codegen(codegen_scope *s, node *tree, int val)
if (val) {
node *n = tree;
if (!n) break;
if (!n) {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
push();
break;
}
codegen(s, n->car, VAL);
n = n->cdr;
while (n) {
@@ -6541,7 +6541,7 @@ mrb_parser_dump(mrb_state *mrb, node *tree, int offset)
case NODE_HEREDOC:
printf("NODE_HEREDOC (<<%s):\n", ((parser_heredoc_info*)tree)->term);
mrb_parser_dump(mrb, ((parser_heredoc_info*)tree)->doc, offset+1);
dump_recur(mrb, ((parser_heredoc_info*)tree)->doc, offset+1);
break;
default:
View
@@ -0,0 +1,10 @@
##
# Codegen tests
assert('nested empty heredoc') do
_, a = nil, <<B
#{<<A}
A
B
assert_equal "\n", a
end

0 comments on commit 73e4f06

Please sign in to comment.