Fix memory leak in parser for invalid syntax
The strterm is leaked when there is invalid syntax. For example: 10.times do 100_000.times do begin RubyVM::InstructionSequence.compile('private def foo = puts "Hello"') rescue SyntaxError end end puts `ps -o rss= -p #{$$}` end Before: 20384 26256 32592 36720 42016 47888 53248 57456 62928 65936 After: 16720 17488 17616 17616 17616 17616 17616 17616 17616 16032 Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
This commit is contained in:
parent
38bc107f0b
commit
02d8bad6e1
1
parse.y
1
parse.y
@ -7618,6 +7618,7 @@ yycompile0(VALUE arg)
|
|||||||
RUBY_DTRACE_PARSE_HOOK(END);
|
RUBY_DTRACE_PARSE_HOOK(END);
|
||||||
p->debug_lines = 0;
|
p->debug_lines = 0;
|
||||||
|
|
||||||
|
xfree(p->lex.strterm);
|
||||||
p->lex.strterm = 0;
|
p->lex.strterm = 0;
|
||||||
p->lex.pcur = p->lex.pbeg = p->lex.pend = 0;
|
p->lex.pcur = p->lex.pbeg = p->lex.pend = 0;
|
||||||
if (n || p->error_p) {
|
if (n || p->error_p) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user