Browse Source

Fixed a possible memory leak

Marco Bambini 1 year ago
parent
commit
a31e74d5dd
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/compiler/gravity_parser.c

+ 4 - 1
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);
     }