summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-11-12 14:37:16 +0900
committerYusuke Endoh <mame@ruby-lang.org>2021-11-12 17:36:39 +0900
commit415671a28273e5bfbe9aa00a0e386f025720ac23 (patch)
treef20952ce167ff86b3901cdb6ccd23dd5fe61aaf0 /parse.y
parent61938e2db59a032a46fc3de2ebead2e5e9d630a9 (diff)
parse.y: Fix memory leak at parse error
Local variable tables might leak at the parse error.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5111
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y6
1 files changed, 6 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 6461b73c73..8bfb7f2757 100644
--- a/parse.y
+++ b/parse.y
@@ -6353,11 +6353,17 @@ yycompile(VALUE vparser, struct parser_params *p, VALUE fname, int line)
}
p->ruby_sourceline = line - 1;
+ p->lvtbl = NULL;
+
p->ast = ast = rb_ast_new();
rb_suppress_tracing(yycompile0, (VALUE)p);
p->ast = 0;
RB_GC_GUARD(vparser); /* prohibit tail call optimization */
+ while (p->lvtbl) {
+ local_pop(p);
+ }
+
return ast;
}
#endif /* !RIPPER */