From cb90e5b9e2ad7ce2a9d586cf82a9756ecd5ecf00 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 7 Oct 2018 16:11:00 -0700 Subject: [PATCH] libedit: Fix memory leak The copy of the original lib_part was not released when aliases could not be located. --- eeschema/lib_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eeschema/lib_manager.cpp b/eeschema/lib_manager.cpp index f09024b2cd..6d5da07cb0 100644 --- a/eeschema/lib_manager.cpp +++ b/eeschema/lib_manager.cpp @@ -422,7 +422,7 @@ bool LIB_MANAGER::UpdatePartAfterRename( LIB_PART* aPart, const wxString& oldAli auto partBuf = libBuf.GetBuffer( oldAlias ); wxCHECK( partBuf, false ); - LIB_PART* original = new LIB_PART( *partBuf->GetOriginal() ); + std::unique_ptr original( new LIB_PART( *partBuf->GetOriginal() ) ); // Save the screen object, so it is transferred to the new buffer std::unique_ptr screen = partBuf->RemoveScreen(); @@ -435,7 +435,7 @@ bool LIB_MANAGER::UpdatePartAfterRename( LIB_PART* aPart, const wxString& oldAli partBuf = libBuf.GetBuffer( aPart->GetName() ); partBuf->SetScreen( std::move( screen ) ); wxCHECK( partBuf, false ); - partBuf->SetOriginal( original ); // part buffer takes ownership of pointer + partBuf->SetOriginal( original.release() ); // part buffer takes ownership of pointer m_frame.SyncLibraries( false );