From 0842a107fbf9cdfff100505b3e155678ceae3974 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 19 Dec 2015 10:49:48 +0100 Subject: [PATCH] Fix Bug #1527804 (Eeschema crashes when loading malformed libraries (mainly incorrect libs converted from Eagle) --- 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 755dcd81d3..8941a05d70 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] );