[Bug #20521] ripper: Clean up strterm
This commit is contained in:
parent
f465045dd6
commit
27321290d9
3
parse.y
3
parse.y
@ -15668,6 +15668,9 @@ rb_ruby_parser_free(void *ptr)
|
|||||||
st_free_table(p->case_labels);
|
st_free_table(p->case_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xfree(p->lex.strterm);
|
||||||
|
p->lex.strterm = 0;
|
||||||
|
|
||||||
xfree(ptr);
|
xfree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,18 +253,31 @@ world"
|
|||||||
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
InvalidHeredocInsideBlockParam = <<~CODE
|
||||||
|
a do |b
|
||||||
|
<<-C
|
||||||
|
C
|
||||||
|
|
|
||||||
|
end
|
||||||
|
CODE
|
||||||
|
|
||||||
def test_heredoc_inside_block_param
|
def test_heredoc_inside_block_param
|
||||||
bug = '[Bug #19399]'
|
bug = '[Bug #19399]'
|
||||||
code = <<~CODE
|
code = InvalidHeredocInsideBlockParam
|
||||||
a do |b
|
|
||||||
<<-C
|
|
||||||
C
|
|
||||||
|
|
|
||||||
end
|
|
||||||
CODE
|
|
||||||
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_heredoc_no_memory_leak
|
||||||
|
assert_no_memory_leak([], "#{<<-"begin;"}", "#{<<-'end;'}", rss: true)
|
||||||
|
require "ripper"
|
||||||
|
source = "" #{InvalidHeredocInsideBlockParam.dump}
|
||||||
|
begin;
|
||||||
|
400_000.times do
|
||||||
|
Ripper.new(source).parse
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
def test_heredoc_unterminated_interpolation
|
def test_heredoc_unterminated_interpolation
|
||||||
code = <<~'HEREDOC'
|
code = <<~'HEREDOC'
|
||||||
<<A+1
|
<<A+1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user