← Back to team overview

kicad-developers team mailing list archive

[PATCH] Crash if a footprint in a library contains a net

 

If a footprint in a library has a net specified for one of its pads, 
pcbnew crashes when it tries to load the library. It's not exactly a 
common bug to encounter, since modedit doesn't actually let you do this 
(you'd have to edit the file manually), but hey, nobody likes segfaults, 
right? :)

commit 3390a804fa118af44357eb089a52267469295614
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
Date:   Wed Jul 29 10:25:21 2015 -0400

    Do not crash if a net is present in a footprint

diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp
index d92f068..19e4494 100644
--- a/pcbnew/pcb_parser.cpp
+++ b/pcbnew/pcb_parser.cpp
@@ -2316,7 +2316,7 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR )
                                       GetChars( CurSource() ), CurLineNumber(), CurOffset() )
                     );
             NeedSYMBOLorNUMBER();
-            if( FromUTF8() != m_board->FindNet( pad->GetNetCode() )->GetNetname() )
+            if( m_board && FromUTF8() != m_board->FindNet( pad->GetNetCode() )->GetNetname() )
                 THROW_IO_ERROR(
                     wxString::Format( _( "invalid net ID in\nfile: <%s>\nline: %d\noffset: %d" ),
                         GetChars( CurSource() ), CurLineNumber(), CurOffset() )

Follow ups