From a85408d8efea2fe931968a5f44cd4a6b5328a8fe Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 8 Jun 2025 11:45:25 +0100 Subject: [PATCH] Nullptr safety. --- common/libeval_compiler/libeval_compiler.cpp | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index a6027318bd..6eb8876ba0 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -1177,21 +1177,20 @@ void UOP::Exec( CONTEXT* ctx ) // TODO: (and do this independently of unit specifics - e.g. MM + INCH needs to return one of the dimension // TODO: types, but our units framework doesn't currently allow this. Therefore, use some heuristics to // TODO: determine the resulting operation unit type for now - auto getOpResultUnits = []( const VALUE* aVal1, const VALUE* aVal2 ) - { - // This condition can occur in, e.g., a unary negation operation - if( aVal1->GetUnits() == EDA_UNITS::UNSCALED && aVal2->GetUnits() != EDA_UNITS::UNSCALED ) - { - return aVal2->GetUnits(); - } + auto getOpResultUnits = + []( const VALUE* aVal1, const VALUE* aVal2 ) + { + wxCHECK( aVal1 && aVal2, EDA_UNITS::UNSCALED ); - if( aVal1->GetUnits() != EDA_UNITS::UNSCALED && aVal2->GetUnits() == EDA_UNITS::UNSCALED ) - { - return aVal1->GetUnits(); - } + // This condition can occur in, e.g., a unary negation operation + if( aVal1->GetUnits() == EDA_UNITS::UNSCALED && aVal2->GetUnits() != EDA_UNITS::UNSCALED ) + return aVal2->GetUnits(); - return aVal2->GetUnits(); - }; + if( aVal1->GetUnits() != EDA_UNITS::UNSCALED && aVal2->GetUnits() == EDA_UNITS::UNSCALED ) + return aVal1->GetUnits(); + + return aVal2->GetUnits(); + }; EDA_UNITS resultUnits = EDA_UNITS::UNSCALED;