Add some defensive code to prevent crashes

Need to avoid the cases where we might have a missing board or an
undefined netclass before dereferencing

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22126
This commit is contained in:
Seth Hillbrand
2025-12-31 15:06:44 -08:00
parent 540f190875
commit e966185b43
2 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -1314,7 +1314,7 @@ static void hasNetclassFunc( LIBEVAL::CONTEXT* aCtx, void* self )
BOARD_CONNECTED_ITEM* bcItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
NETCLASS* netclass = bcItem->GetEffectiveNetClass();
if( netclass->ContainsNetclassWithName( arg->AsString() ) )
if( netclass && netclass->ContainsNetclassWithName( arg->AsString() ) )
return 1.0;
return 0.0;
@@ -1353,7 +1353,7 @@ static void hasExactNetclassFunc( LIBEVAL::CONTEXT* aCtx, void* self )
BOARD_CONNECTED_ITEM* bcItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
NETCLASS* netclass = bcItem->GetEffectiveNetClass();
if( netclass->GetName() == arg->AsString() )
if( netclass && netclass->GetName() == arg->AsString() )
return 1.0;
return 0.0;