From c82679a6f270af29f374e4c9f082bbe458ffc13f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 12 Apr 2020 11:18:40 +0100 Subject: [PATCH] Fix crash bug when highlighting no net (found by Coverity). --- eeschema/tools/sch_editor_control.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 10e2501d94..cf553bc945 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -714,10 +714,13 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) SCH_ITEM* item = static_cast( selTool->GetNode( aPosition ) ); SCH_COMPONENT* comp = nullptr; - if( item->Type() == SCH_FIELD_T ) - comp = dynamic_cast( item->GetParent() ); - else - comp = dynamic_cast( item ); + if( item ) + { + if( item->Type() == SCH_FIELD_T ) + comp = dynamic_cast( item->GetParent() ); + else + comp = dynamic_cast( item ); + } if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() ) netName = comp->GetPartRef()->GetName();