From 712215fe12fde84a925ec8e2b4367f7fb1733620 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> Date: Thu, 27 Aug 2020 14:52:01 +0200 Subject: [PATCH] libeval_compiler: fix crash when preflighting method calls with 0 arguments --- common/libeval_compiler/libeval_compiler.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index f711c5b83d..a76024c0e2 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -805,11 +805,17 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext ) if( func ) { // Preflight the function call - wxString paramStr = *node->leaf[1]->leaf[1]->value.str; - VALUE* param = aPreflightContext->AllocValue(); + auto argsLeaf = node->leaf[1]->leaf[1]; + wxString paramStr; - param->Set( paramStr ); - aPreflightContext->Push( param ); + if( argsLeaf->op != TR_NULL ) // function has an argument + { + paramStr = *node->leaf[1]->leaf[1]->value.str; + VALUE* param = aPreflightContext->AllocValue(); + + param->Set( paramStr ); + aPreflightContext->Push( param ); + } aPreflightContext->SetErrorCallback( [&]( const wxString& aMessage, int aOffset )