From 9570ef41f87c41d7f11560ace2949994d027dbec Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Mon, 2 Mar 2026 14:55:29 -0500 Subject: [PATCH] eeschema: guard netclass lookup during schematic parse Malformed schematic content can reference a missing netclass and crash parse-time item setup. Check lookup results before use and fall back safely when the netclass is absent. Found by codex-5.3 --- eeschema/sch_item.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index cb50b55ec4..1f19f7000d 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -512,16 +512,21 @@ std::shared_ptr SCH_ITEM::GetEffectiveNetClass( const SCH_SHEET_PATH* SCHEMATIC* schematic = Schematic(); - if( schematic ) - { - std::shared_ptr& netSettings = schematic->Project().GetProjectFile().m_NetSettings; - SCH_CONNECTION* connection = Connection( aSheet ); + if( !schematic || !schematic->IsValid() ) + return nullNetclass; - if( connection ) - return netSettings->GetEffectiveNetClass( connection->Name() ); - else - return netSettings->GetDefaultNetclass(); - } + std::shared_ptr& netSettings = schematic->Project().GetProjectFile().m_NetSettings; + + if( !netSettings ) + return nullNetclass; + + SCH_CONNECTION* connection = Connection( aSheet ); + + if( connection ) + return netSettings->GetEffectiveNetClass( connection->Name() ); + + if( std::shared_ptr defaultNetclass = netSettings->GetDefaultNetclass() ) + return defaultNetclass; return nullNetclass; }