From a31e74d5ddbe84d627a5db2cf6980035b97eccc2 Mon Sep 17 00:00:00 2001 From: Marco Bambini Date: Fri, 31 May 2024 09:47:25 +0200 Subject: [PATCH] Fixed a possible memory leak --- src/compiler/gravity_parser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/gravity_parser.c b/src/compiler/gravity_parser.c index b5a6a7c..5c95962 100644 --- a/src/compiler/gravity_parser.c +++ b/src/compiler/gravity_parser.c @@ -437,7 +437,10 @@ static gnode_t *parse_file_expression (gravity_parser_t *parser) { while (gravity_lexer_peek(lexer) == TOK_OP_DOT) { gravity_lexer_next(lexer); // consume TOK_OP_DOT const char *identifier = parse_identifier(parser); - if (!identifier) return NULL; + if (!identifier) { + mem_free(list); + return NULL; + } cstring_array_push(list, identifier); }