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; }