Eeschema: fix segfault when loading malformed libraries. (fixes lp:1527804)

This commit is contained in:
Jean-Pierre Charras 2015-12-20 16:46:33 -05:00 committed by Wayne Stambaugh
parent b526227529
commit 2f7b3ab56e
1 changed files with 10 additions and 2 deletions

View File

@ -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] );