PCB: check ratsnest for nullptr (segfaults)

This commit is contained in:
Mike Williams 2023-08-24 10:51:34 -04:00
parent d9c2e0ab54
commit 9079df85fd
2 changed files with 16 additions and 1 deletions

View File

@ -967,6 +967,9 @@ CONNECTIVITY_DATA::GetRatsnestForItems( const std::vector<BOARD_ITEM*>& aItems )
{ {
RN_NET* net = GetRatsnestForNet( netcode ); RN_NET* net = GetRatsnestForNet( netcode );
if( !net )
continue;
for( const CN_EDGE& edge : net->GetEdges() ) for( const CN_EDGE& edge : net->GetEdges() )
{ {
std::shared_ptr<const CN_ANCHOR> srcNode = edge.GetSourceNode(); std::shared_ptr<const CN_ANCHOR> srcNode = edge.GetSourceNode();
@ -992,6 +995,9 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForPad( const PAD* aPad
std::vector<CN_EDGE> edges; std::vector<CN_EDGE> edges;
RN_NET* net = GetRatsnestForNet( aPad->GetNetCode() ); RN_NET* net = GetRatsnestForNet( aPad->GetNetCode() );
if( !net )
return edges;
for( const CN_EDGE& edge : net->GetEdges() ) for( const CN_EDGE& edge : net->GetEdges() )
{ {
if( edge.GetSourceNode()->Parent() == aPad || edge.GetTargetNode()->Parent() == aPad ) if( edge.GetSourceNode()->Parent() == aPad || edge.GetTargetNode()->Parent() == aPad )
@ -1017,7 +1023,12 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForComponent( FOOTPRINT
for( int netcode : nets ) for( int netcode : nets )
{ {
for( const CN_EDGE& edge : GetRatsnestForNet( netcode )->GetEdges() ) RN_NET* net = GetRatsnestForNet( netcode );
if( !net )
continue;
for( const CN_EDGE& edge : net->GetEdges() )
{ {
const std::shared_ptr<const CN_ANCHOR>& srcNode = edge.GetSourceNode(); const std::shared_ptr<const CN_ANCHOR>& srcNode = edge.GetSourceNode();
const std::shared_ptr<const CN_ANCHOR>& dstNode = edge.GetTargetNode(); const std::shared_ptr<const CN_ANCHOR>& dstNode = edge.GetTargetNode();

View File

@ -1682,6 +1682,10 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
// the side of the connectivity on this pad. It also checks for ratsnest points // the side of the connectivity on this pad. It also checks for ratsnest points
// inside the pad (like a trace end) and counts them. // inside the pad (like a trace end) and counts them.
RN_NET* net = connectivity->GetRatsnestForNet( item->GetNetCode() ); RN_NET* net = connectivity->GetRatsnestForNet( item->GetNetCode() );
if( !net )
continue;
std::vector<std::shared_ptr<const CN_ANCHOR>> anchors; std::vector<std::shared_ptr<const CN_ANCHOR>> anchors;
for( const CN_EDGE& edge : net->GetEdges() ) for( const CN_EDGE& edge : net->GetEdges() )