From 1a520d4b45af8cfe3ccbb8e0d353034ceac4beac Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Mon, 2 Mar 2026 14:56:46 -0500 Subject: [PATCH] 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 --- eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp | 6 ++++++ eeschema/sch_table.cpp | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index ff3f7312ff..67fc32bca8 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -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(); } diff --git a/eeschema/sch_table.cpp b/eeschema/sch_table.cpp index 8723818511..9ee8042b2b 100644 --- a/eeschema/sch_table.cpp +++ b/eeschema/sch_table.cpp @@ -261,7 +261,9 @@ void SCH_TABLE::RunOnChildren( const std::function& 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() );