From e4c857185fed9285f9d1e4123fc8d6ebcfa5f4c3 Mon Sep 17 00:00:00 2001 From: Pietro Fezzardi Date: Tue, 18 May 2021 18:22:20 +0200 Subject: [PATCH] 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. --- lib/Decompiler/DLATypeSystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Decompiler/DLATypeSystem.cpp b/lib/Decompiler/DLATypeSystem.cpp index e43553c3c..3303088bd 100644 --- a/lib/Decompiler/DLATypeSystem.cpp +++ b/lib/Decompiler/DLATypeSystem.cpp @@ -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); }