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:
Mike Williams
2026-03-02 14:56:46 -05:00
parent 3d5ac858db
commit 1a520d4b45
2 changed files with 9 additions and 1 deletions
@@ -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();
}
+3 -1
View File
@@ -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() );