From 05ab44f4633299148578bc211250d972a447a206 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 31 Oct 2017 09:14:03 +0100 Subject: [PATCH] Fixed a memleak when no undo entry is requested in BOARD_COMMIT --- pcbnew/board_commit.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index df2a1923d5..dcb504b4e4 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -264,9 +264,16 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry ) module->RunOnChildren( [&view] ( BOARD_ITEM* aItem ) { view->Update( aItem ); } ); } - view->Update ( boardItem ); - connectivity->MarkItemNetAsDirty( static_cast( ent.m_copy ) ); + if( ent.m_copy ) + connectivity->MarkItemNetAsDirty( static_cast( ent.m_copy ) ); + connectivity->Update( boardItem ); + view->Update( boardItem ); + + // if no undo entry is needed, the copy would create a memory leak + if( !aCreateUndoEntry ) + delete ent.m_copy; + break; }