summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-06-21 11:25:13 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2023-06-22 09:19:36 -0700
commitb879528e24272d8fbe41fe0e4e07cadcca5b643c (patch)
treef7174c9e57d02dc70c74931cc47e1ce4f50d8f1f
parentedd488109fe8a95ec8674886905fe503fc0f9108 (diff)
[ruby/yarp] Do not leak memory from lex modes
https://github.com/ruby/yarp/commit/df6661740c
-rw-r--r--yarp/yarp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c
index db9a7ba562..0475c44836 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -12841,6 +12841,10 @@ yp_parser_free(yp_parser_t *parser) {
yp_comment_list_free(&parser->comment_list);
yp_constant_pool_free(&parser->constant_pool);
yp_newline_list_free(&parser->newline_list);
+
+ while (parser->lex_modes.index >= YP_LEX_STACK_SIZE) {
+ lex_mode_pop(parser);
+ }
}
// Parse the Ruby source associated with the given parser and return the tree.