소스 검색

Fixed a possible memory leak

Marco Bambini 1 년 전
부모
커밋
a31e74d5dd
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  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);
     }