Skip to content

Commit

Permalink
Merge pull request #23 from LangProc/fix-mem-leak
Browse files Browse the repository at this point in the history
Fixed memory leaks in parser
  • Loading branch information
simon-staal authored Mar 11, 2024
2 parents 574d65e + e58cb78 commit 0b74087
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -202,5 +203,7 @@ Node *ParseAST(std::string file_name)
}
g_root = nullptr;
yyparse();
fclose(yyin);
yylex_destroy();
return g_root;
}
3 changes: 3 additions & 0 deletions src/parser_full.y.example
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -468,5 +469,7 @@ Node *ParseAST(std::string file_name)
}
g_root = nullptr;
yyparse();
fclose(yyin);
yylex_destroy();
return g_root;
}

0 comments on commit 0b74087

Please sign in to comment.