From 61fcfd593813c55949ba4e234a4214a2b9eced92 Mon Sep 17 00:00:00 2001 From: Jarek Prokop Date: Thu, 1 Feb 2024 16:53:39 +0100 Subject: [PATCH] Prevent resource leak with type/method-type parser when reaching EOF. --- ext/rbs_extension/parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/rbs_extension/parser.c b/ext/rbs_extension/parser.c index 01af4323c..15400209e 100644 --- a/ext/rbs_extension/parser.c +++ b/ext/rbs_extension/parser.c @@ -2763,6 +2763,7 @@ rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, V parserstate *parser = alloc_parser(buffer, FIX2INT(start_pos), FIX2INT(end_pos), variables); if (parser->next_token.type == pEOF) { + free_parser(parser); return Qnil; } @@ -2783,6 +2784,7 @@ rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end parserstate *parser = alloc_parser(buffer, FIX2INT(start_pos), FIX2INT(end_pos), variables); if (parser->next_token.type == pEOF) { + free_parser(parser); return Qnil; }