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:
+14
-9
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user