From 2f7b3ab56e002d2eafff3dd871dbce436ddaddda Mon Sep 17 00:00:00 2001 From: Jean-Pierre Charras Date: Sun, 20 Dec 2015 16:46:33 -0500 Subject: [PATCH] Eeschema: fix segfault when loading malformed libraries. (fixes lp:1527804) --- eeschema/class_libentry.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 1d49ea3e42..cca83e4337 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -886,7 +886,7 @@ bool LIB_PART::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) { p = strtok( line, " \t\n" ); - if( stricmp( p, "ENDDEF" ) == 0 ) + if( p && stricmp( p, "ENDDEF" ) == 0 ) break; } @@ -948,6 +948,9 @@ bool LIB_PART::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) if( *line == '#' ) // a comment continue; + if( p == NULL ) // empty line + continue; + if( line[0] == 'T' && line[1] == 'i' ) result = LoadDateAndTime( aLineReader ); else if( *line == 'F' ) @@ -1036,7 +1039,12 @@ bool LIB_PART::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorMsg ) break; case '#': // Comment - continue; + continue; + + case '\n': + case '\r': + case 0: // empty line + continue; default: aErrorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] );