router: fix use-after-free error when dragging a single (no tracks attached via) in shove mode

Fixes: https://gitlab.com/kicad/code/kicad/-/work_items/23449

(cherry picked from commit 1909f3a8b3)
This commit is contained in:
Tomasz Wlostowski
2026-03-16 21:58:43 +01:00
parent 7a1121bd62
commit b781fc29a7
+5 -16
View File
@@ -2443,29 +2443,13 @@ SHOVE::SHOVE_STATUS SHOVE::Run()
m_currentNode = parent->Branch();
m_currentNode->ClearRanks();
//nodeStats( Dbg(), m_currentNode, "right-after-branch" );
auto iface = Router()->GetInterface();
// for ( auto& hq : m_headLines )
// if( hq.oldHead )
// m_currentNode->Remove( *hq.oldHead );
// Push the via to its new location
for( auto& headLineEntry : m_headLines )
{
//if( rootEntry->line ) // head already processed in previous steps
//{
// PNS_DBG( Dbg(), Message, wxString::Format( "RL found" ) );
//continue;
//}
m_currentNode->ClearRanks();
if( headLineEntry.theVia )
@@ -2619,6 +2603,11 @@ SHOVE::SHOVE_STATUS SHOVE::Run()
}
}
// NODE's destructor invalidates all linked items in the LINEs stored in the stack/queue
// Erase them first to avoid a use-after-free issue.
m_lineStack.clear();
m_optimizerQueue.clear();
pruneRootLines( m_currentNode );
delete m_currentNode;