gerbview: Prevent NULL dereference

There was a possible NULL dereference when executing tool_up even
though we should never hit it, we protect against bad files.

Also converts a couple untranslated error strings.
This commit is contained in:
Seth Hillbrand 2018-10-10 23:11:10 -07:00
parent a16e21665a
commit d03b08a03f
1 changed files with 8 additions and 2 deletions

View File

@ -385,7 +385,7 @@ bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName )
default: default:
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "Unexpected symbol <%c>" ), *text ); msg.Printf( _( "Unexpected symbol <%c>" ), *text );
AddMessageToList( msg ); AddMessageToList( msg );
} }
break; break;
@ -431,7 +431,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_And_M_Command( char*& text )
if( !cmd ) if( !cmd )
{ {
msg.Printf( wxT( "Unknown Excellon command <%s>" ), text ); msg.Printf( _( "Unknown Excellon command <%s>" ), text );
AddMessageToList( msg ); AddMessageToList( msg );
while( *text ) while( *text )
text++; text++;
@ -560,6 +560,12 @@ bool EXCELLON_IMAGE::Execute_HEADER_And_M_Command( char*& text )
{ {
D_CODE* tool = GetDCODE( m_Current_Tool ); D_CODE* tool = GetDCODE( m_Current_Tool );
if( !tool )
{
AddMessageToList( wxString::Format( _( "Got unknown tool code %d" ), m_Current_Tool ) );
break;
}
for( size_t ii = 1; ii < m_RoutePositions.size(); ii++ ) for( size_t ii = 1; ii < m_RoutePositions.size(); ii++ )
{ {
GERBER_DRAW_ITEM* gbritem = new GERBER_DRAW_ITEM( this ); GERBER_DRAW_ITEM* gbritem = new GERBER_DRAW_ITEM( this );