Skip to content

Commit c478744

Browse files
committed
Fix memory leak on AST
AST was leaking the singleton pointer. Signed-off-by: Rafael Campos Nunes <rafaelnunes@engineer.com>
1 parent 6f5aaa1 commit c478744

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/ast/general/ASTInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ ASTInfo* ASTInfo::instance()
2222
return ASTInfo::_instance;
2323
}
2424

25+
ASTInfo::~ASTInfo() {
26+
delete _instance;
27+
}
28+
2529
llvm::GlobalVariable* ASTInfo::get_index_ptr()
2630
{
2731
return __brain_index_ptr;

src/ast/general/ASTInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ASTInfo
3535
public:
3636
ASTInfo(ASTInfo const&) = delete;
3737
ASTInfo& operator=(ASTInfo const&) = delete;
38+
~ASTInfo();
3839
/**
3940
* @brief Returns the instance of ASTInfo class if the member _instance is
4041
* nullptr, otherwise it creates a new ASTInfo object and returns it.

0 commit comments

Comments
 (0)