LayoutTypeSystem: fix memory leak

Not calling the destructor of LayoutTypeSystemNode before their
deallocation was leaking pairs of Successors and Predecessors.

This commit fixes it by explicitly destructing LayoutTypeSystemNodes.
This commit is contained in:
Pietro Fezzardi
2021-05-18 18:22:20 +02:00
parent 7d4a1ba467
commit e4c857185f
+2
View File
@@ -641,6 +641,7 @@ void LayoutTypeSystem::mergeNodes(const LayoutTypeSystemNodePtrVec &ToMerge) {
// Remove From from Layouts
bool Erased = Layouts.erase(From);
revng_assert(Erased);
From->~LayoutTypeSystemNode();
NodeAllocator.Deallocate(From);
}
}
@@ -675,6 +676,7 @@ void LayoutTypeSystem::removeNode(LayoutTypeSystemNode *ToRemove) {
bool Erased = Layouts.erase(ToRemove);
revng_assert(Erased);
ToRemove->~LayoutTypeSystemNode();
NodeAllocator.Deallocate(ToRemove);
}