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
This commit is contained in:
Mike Williams
2026-03-02 14:55:29 -05:00
parent 6f489fccd4
commit 9570ef41f8
+14 -9
View File
@@ -512,16 +512,21 @@ std::shared_ptr<NETCLASS> SCH_ITEM::GetEffectiveNetClass( const SCH_SHEET_PATH*
SCHEMATIC* schematic = Schematic();
if( schematic )
{
std::shared_ptr<NET_SETTINGS>& 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<NET_SETTINGS>& 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<NETCLASS> defaultNetclass = netSettings->GetDefaultNetclass() )
return defaultNetclass;
return nullNetclass;
}