Skip to content

Commit f4c4b94

Browse files
authored
Fix memory leaks in the code (#2753)
* Add list recursive freeing * Add separate chaining free logic * Add freeing logic to sets * Fix double free error * Remove warning raising code
1 parent 759df0e commit f4c4b94

File tree

3 files changed

+388
-27
lines changed

3 files changed

+388
-27
lines changed

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,13 +2208,14 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
22082208
}
22092209

22102210
void visit_ListClear(const ASR::ListClear_t& x) {
2211+
ASR::List_t* asr_list = ASR::down_cast<ASR::List_t>(ASRUtils::expr_type(x.m_a));
22112212
int64_t ptr_loads_copy = ptr_loads;
22122213
ptr_loads = 0;
22132214
this->visit_expr(*x.m_a);
22142215
llvm::Value* plist = tmp;
22152216
ptr_loads = ptr_loads_copy;
22162217

2217-
list_api->list_clear(plist);
2218+
list_api->list_clear(plist, asr_list->m_type, module.get());
22182219
}
22192220

22202221
void visit_ListRepeat(const ASR::ListRepeat_t& x) {

0 commit comments

Comments
 (0)