From a1646bbd6c9f9fa7fb7d731100ca81dbd9d4e674 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 27 Jan 2025 18:28:41 +0100 Subject: [PATCH] Pcbnew, router: fix crash when trying to create a blind via without a track Using PnS router, when trying to create a blind/buried or micro via with layer selection with no track in progress, the router crashed because the starting layer was not defined. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19750 (cherry picked from commit 32673a0ead87a05000596d805fabb11cb8a1083a) --- pcbnew/router/router_tool.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 30828c489c..891efe8b95 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1011,6 +1011,12 @@ int ROUTER_TOOL::handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia ) // ask the user for a target layer if( selectLayer ) { + // When the currentLayer is undefined, trying to place a via does not work + // because it means there is no track in progress, and some other variables + // values are not defined like m_endSnapPoint. So do not continue. + if( currentLayer == UNDEFINED_LAYER ) + return 0; + wxPoint endPoint = ToWxPoint( view()->ToScreen( m_endSnapPoint ) ); endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );