From f6317fba8265dd1f04a366ab4fff9d2c5bc4571c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 6 Mar 2020 09:30:56 -0800 Subject: [PATCH] PNS: Protect drag from null deref Items that do not have nets will not be in the index, so we need to avoid the null pointer when adding drag tagets Fixes https://gitlab.com/kicad/code/kicad/issues/4009 --- pcbnew/router/pns_node.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index a074d5b74f..a3b2160cad 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -1444,9 +1444,12 @@ ITEM *NODE::FindItemByParent( const BOARD_CONNECTED_ITEM* aParent ) { INDEX::NET_ITEMS_LIST* l_cur = m_index->GetItemsForNet( aParent->GetNetCode() ); - for( ITEM*item : *l_cur ) - if( item->Parent() == aParent ) - return item; + if( l_cur ) + { + for( ITEM* item : *l_cur ) + if( item->Parent() == aParent ) + return item; + } return NULL; }