libedit: Fix memory leak

The copy of the original lib_part was not released when aliases could
not be located.
This commit is contained in:
Seth Hillbrand 2018-10-07 16:11:00 -07:00
parent 1828e8cb0f
commit cb90e5b9e2
1 changed files with 2 additions and 2 deletions

View File

@ -422,7 +422,7 @@ bool LIB_MANAGER::UpdatePartAfterRename( LIB_PART* aPart, const wxString& oldAli
auto partBuf = libBuf.GetBuffer( oldAlias ); auto partBuf = libBuf.GetBuffer( oldAlias );
wxCHECK( partBuf, false ); wxCHECK( partBuf, false );
LIB_PART* original = new LIB_PART( *partBuf->GetOriginal() ); std::unique_ptr<LIB_PART> original( new LIB_PART( *partBuf->GetOriginal() ) );
// Save the screen object, so it is transferred to the new buffer // Save the screen object, so it is transferred to the new buffer
std::unique_ptr<SCH_SCREEN> screen = partBuf->RemoveScreen(); std::unique_ptr<SCH_SCREEN> screen = partBuf->RemoveScreen();
@ -435,7 +435,7 @@ bool LIB_MANAGER::UpdatePartAfterRename( LIB_PART* aPart, const wxString& oldAli
partBuf = libBuf.GetBuffer( aPart->GetName() ); partBuf = libBuf.GetBuffer( aPart->GetName() );
partBuf->SetScreen( std::move( screen ) ); partBuf->SetScreen( std::move( screen ) );
wxCHECK( partBuf, false ); 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 ); m_frame.SyncLibraries( false );