From b49fbf0cd6ada33a3e0a5850bd8b7b82efd76502 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 11 Nov 2016 22:58:39 +0100 Subject: [PATCH] Another this==nullptr fix (#828) --- src/CBot/CBotDefParam.cpp | 1 + src/CBot/CBotInstr/CBotFunction.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/CBot/CBotDefParam.cpp b/src/CBot/CBotDefParam.cpp index d73c02e0..ff4acf1f 100644 --- a/src/CBot/CBotDefParam.cpp +++ b/src/CBot/CBotDefParam.cpp @@ -104,6 +104,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack) bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) { int i = 0; + assert(this != nullptr); CBotDefParam* p = this; while ( p != nullptr ) diff --git a/src/CBot/CBotInstr/CBotFunction.cpp b/src/CBot/CBotInstr/CBotFunction.cpp index c8db69a9..f86153f5 100644 --- a/src/CBot/CBotInstr/CBotFunction.cpp +++ b/src/CBot/CBotInstr/CBotFunction.cpp @@ -334,7 +334,10 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance) if ( pile->GetState() == 0 ) { - if ( !m_param->Execute(ppVars, pile) ) return false; // define parameters + if (m_param != nullptr) + { + if ( !m_param->Execute(ppVars, pile) ) return false; // define parameters + } pile->IncState(); } @@ -647,7 +650,10 @@ int CBotFunction::DoCall(CBotProgram* program, const std::list& l } // initializes the variables as parameters - pt->m_param->Execute(ppVars, pStk3); // cannot be interrupted + if (pt->m_param != nullptr) + { + pt->m_param->Execute(ppVars, pStk3); // cannot be interrupted + } pStk1->IncState(); } @@ -766,7 +772,10 @@ int CBotFunction::DoCall(const std::list& localFunctionList, long pStk->AddVar(psuper); } // initializes the variables as parameters - pt->m_param->Execute(ppVars, pStk3); // cannot be interrupted + if (pt->m_param != nullptr) + { + pt->m_param->Execute(ppVars, pStk3); // cannot be interrupted + } pStk->IncState(); }