eeschema: reject empty schematic tables during parse
Empty table nodes from malformed input can leave table state invalid and crash later accesses. Found by codex-5.3
This commit is contained in:
@@ -5037,6 +5037,12 @@ SCH_TABLE* SCH_IO_KICAD_SEXPR_PARSER::parseSchTable()
|
||||
}
|
||||
}
|
||||
|
||||
if( !table->GetCell( 0, 0 ) )
|
||||
{
|
||||
THROW_PARSE_ERROR( _( "Invalid table: no cells defined" ), CurSource(), CurLine(), CurLineNumber(),
|
||||
CurOffset() );
|
||||
}
|
||||
|
||||
return table.release();
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,9 @@ void SCH_TABLE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction
|
||||
|
||||
const BOX2I SCH_TABLE::GetBoundingBox() const
|
||||
{
|
||||
// Note: a table with no cells is not allowed
|
||||
if( m_cells.empty() )
|
||||
return BOX2I();
|
||||
|
||||
BOX2I bbox = m_cells[0]->GetBoundingBox();
|
||||
|
||||
bbox.Merge( m_cells[m_cells.size() - 1]->GetBoundingBox() );
|
||||
|
||||
Reference in New Issue
Block a user