From 5a33772f4141e44b96810596cf341a297381fda6 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 6 Aug 2020 16:11:55 +0200 Subject: [PATCH] Pcbnew: avoid crash when saving a board having "orphan" nets. Sometimes tracks or zones can have "orphan" nets no longer existing in schematic after updating the board from the schematic (no pad belonging this net). The fix does not save these broken nets having no info (no netname, no valid netcode) Fixes #5087 https://gitlab.com/kicad/code/kicad/issues/5087 --- pcbnew/kicad_plugin.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index d617a81e7e..6686ae849b 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -579,6 +579,9 @@ void PCB_IO::formatNetInformation( BOARD* aBoard, int aNestLevel ) const { for( NETINFO_ITEM* net : *m_mapping ) { + if( net == nullptr ) // Skip not actually existing nets (orphan nets) + continue; + m_out->Print( aNestLevel, "(net %d %s)\n", m_mapping->Translate( net->GetNet() ), m_out->Quotew( net->GetNetname() ).c_str() );