Fix null dereference for certain bad PCB files
Coverity: CID 147344 Unchecked dynamic_cast If a file that parses validly in Parse() but does not return a BOARD is loaded, no exception will be thrown but the dynamic_cast will return NULL. This NULL is tested by wxASSERT(), which does not actually halt anything (especially in release builds), and then we proceed to board->SetFileName(). This can be demonstrated quickly by renaming a .kicad_mod to .kicad_pcb and trying to load it. pcbnew will crash.
This commit is contained in:
parent
445db7da58
commit
7b5ab741bb
|
@ -1745,7 +1745,13 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPER
|
|||
throw;
|
||||
}
|
||||
|
||||
wxASSERT( board );
|
||||
if( !board )
|
||||
{
|
||||
// The parser loaded something that was valid, but wasn't a board.
|
||||
THROW_PARSE_ERROR( _( "this file does not contain a PCB" ),
|
||||
m_parser->CurSource(), m_parser->CurLine(),
|
||||
m_parser->CurLineNumber(), m_parser->CurOffset() );
|
||||
}
|
||||
|
||||
// Give the filename to the board if it's new
|
||||
if( !aAppendToMe )
|
||||
|
|
Loading…
Reference in New Issue