From a4aa447b95a4a21567ba3ef5200e33c4c2dd3186 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 31 May 2022 20:18:16 -0400 Subject: [PATCH] [PNS] Fix invalid assumption in IsLineCorner --- pcbnew/router/pns_joint.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pcbnew/router/pns_joint.h b/pcbnew/router/pns_joint.h index d8dad464d2..fdcb3015ac 100644 --- a/pcbnew/router/pns_joint.h +++ b/pcbnew/router/pns_joint.h @@ -112,11 +112,20 @@ public: && m_linkedItems.Count( SEGMENT_T | ARC_T ) == 2 && m_linkedItems.Count( VIA_T ) == 1 ) { - assert( static_cast( m_linkedItems[2] )->Kind() == VIA_T ); + const VIA* via = nullptr; - const VIA* via = static_cast( m_linkedItems[2] ); + for( const ITEM* item : m_linkedItems.CItems() ) + { + if( item->Kind() == VIA_T ) + { + via = static_cast( item ); + break; + } + } - if( !via->IsVirtual() ) + assert( via ); + + if( !via || !via->IsVirtual() ) return false; } else