Skip to content

Commit

Permalink
Prevent resource leak with type/method-type parser when reaching EOF.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackorp committed Feb 1, 2024
1 parent f424b52 commit 61fcfd5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/rbs_extension/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 61fcfd5

Please sign in to comment.