From 6ab6283e2e89b0e898fa9d75f5a9a8e3c32086f3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 11 Sep 2025 12:48:43 +0100 Subject: [PATCH] LIBEVAL::CONTEXT manages its own local VALUEs. Don't use std::unique_ptr as we'll just free the value right after storing it. Also, don't try to execute a non-existent function. Fixes https://gitlab.com/kicad/code/kicad/-/issues/21697 --- common/libeval_compiler/libeval_compiler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index 442db47bdb..f750715ba7 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -1160,7 +1160,9 @@ void UOP::Exec( CONTEXT* ctx ) return; case TR_OP_METHOD_CALL: - m_func( ctx, m_ref.get() ); + if( m_func ) + m_func( ctx, m_ref.get() ); + return; default: @@ -1321,9 +1323,8 @@ VALUE* UCODE::Run( CONTEXT* ctx ) } catch(...) { - // rules which fail outright should not be fired - std::unique_ptr temp_false = std::make_unique( 0 ); - return ctx->StoreValue( temp_false.get() ); + // rules which fail outright should not be fired; return 0/false + return ctx->StoreValue( new VALUE( 0 ) ); } if( ctx->SP() == 1 ) @@ -1339,8 +1340,7 @@ VALUE* UCODE::Run( CONTEXT* ctx ) wxASSERT( ctx->SP() == 1 ); // non-well-formed rules should not be fired on a release build - std::unique_ptr temp_false = std::make_unique( 0 ); - return ctx->StoreValue( temp_false.get() ); + return ctx->StoreValue( new VALUE( 0 ) ); } }