[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);
|
||||
}
|
||||
|
||||
xfree(p->lex.strterm);
|
||||
p->lex.strterm = 0;
|
||||
|
||||
xfree(ptr);
|
||||
}
|
||||
|
||||
|
@ -253,18 +253,31 @@ world"
|
||||
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
||||
end
|
||||
|
||||
InvalidHeredocInsideBlockParam = <<~CODE
|
||||
a do |b
|
||||
<<-C
|
||||
C
|
||||
|
|
||||
end
|
||||
CODE
|
||||
|
||||
def test_heredoc_inside_block_param
|
||||
bug = '[Bug #19399]'
|
||||
code = <<~CODE
|
||||
a do |b
|
||||
<<-C
|
||||
C
|
||||
|
|
||||
end
|
||||
CODE
|
||||
code = InvalidHeredocInsideBlockParam
|
||||
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
||||
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
|
||||
code = <<~'HEREDOC'
|
||||
<<A+1
|
||||
|
Loading…
x
Reference in New Issue
Block a user