From e58cb78c253fc67ca0bdc6f99d0e849f82fd385f Mon Sep 17 00:00:00 2001 From: Simon Staal Date: Sun, 10 Mar 2024 17:36:21 +0000 Subject: [PATCH] Fixed memory leaks in parser --- src/parser.y | 3 +++ src/parser_full.y.example | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/parser.y b/src/parser.y index 4243310..0100d04 100644 --- a/src/parser.y +++ b/src/parser.y @@ -11,6 +11,7 @@ extern FILE *yyin; int yylex(void); void yyerror(const char *); + int yylex_destroy(void); } // Represents the value associated with any kind of AST node. @@ -202,5 +203,7 @@ Node *ParseAST(std::string file_name) } g_root = nullptr; yyparse(); + fclose(yyin); + yylex_destroy(); return g_root; } diff --git a/src/parser_full.y.example b/src/parser_full.y.example index 29a4148..20c1cf0 100644 --- a/src/parser_full.y.example +++ b/src/parser_full.y.example @@ -7,6 +7,7 @@ extern FILE *yyin; int yylex(void); void yyerror(const char *); + int yylex_destroy(void); } // Represents the value associated with any kind of AST node. @@ -468,5 +469,7 @@ Node *ParseAST(std::string file_name) } g_root = nullptr; yyparse(); + fclose(yyin); + yylex_destroy(); return g_root; }