From 18fb2ddff6bb21a91a99d6ce90be59197ddce9c9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 9 Apr 2022 20:12:07 +0100 Subject: [PATCH] Coverity fixes. --- pcbnew/dialogs/dialog_drc.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 52507e5c93..509b11a16e 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -442,19 +442,22 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent ) } else if( rc_item->GetErrorCode() == DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG ) { - PCB_TRACK* track = dynamic_cast( item ); - int net = track->GetNetCode(); - std::vector segs; + BOARD_CONNECTED_ITEM* connectedItem = dynamic_cast( item ); + int net = connectedItem ? connectedItem->GetNetCode() : -1; + std::vector items; + + wxASSERT( net > 0 ); // Without a net how can it be a diff-pair? for( const KIID& id : rc_item->GetIDs() ) { - PCB_TRACK* candidate = dynamic_cast( board->GetItem( id ) ); + auto* candidate = dynamic_cast( board->GetItem( id ) ); + wxASSERT( candidate ); if( candidate && candidate->GetNetCode() == net ) - segs.push_back( candidate ); + items.push_back( candidate ); } - m_frame->FocusOnItems( segs, principalLayer ); + m_frame->FocusOnItems( items, principalLayer ); } else if( m_centerMarkerOnIdle ) {