diff options
author | krzys-h <krzys_h@interia.pl> | 2013-12-29 16:31:32 +0100 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2013-12-29 16:31:32 +0100 |
commit | 12e17224b37d7db52545c00fb75c0322e0e5afad (patch) | |
tree | a55578be3b129b0602060b8dd91c10ebae7c573b /src | |
parent | a36450a6dae20912ba89a9c49e8b951a20a32bfb (diff) | |
download | colobot-12e17224b37d7db52545c00fb75c0322e0e5afad.tar.gz colobot-12e17224b37d7db52545c00fb75c0322e0e5afad.tar.bz2 colobot-12e17224b37d7db52545c00fb75c0322e0e5afad.zip |
Added nullptr shecks to object.factory()
Trying to fix #275
Diffstat (limited to 'src')
-rw-r--r-- | src/script/script.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp index fbf7276..0518479 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -680,10 +680,23 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e classVars = classVars->GetNext(); // "id" int rank = classVars->GetValInt(); CObject* factory = CObjectManager::GetInstancePointer()->SearchInstance(rank); - CAutoFactory* automat = static_cast<CAutoFactory*>(factory->GetAuto()); + if (factory == nullptr) { + exception = ERR_GENERIC; + result->SetValInt(ERR_GENERIC); + CLogger::GetInstancePointer()->Error("in object.factory() - factory is nullptr"); + return false; + } if ( thisType == OBJECT_FACTORY ) { + CAutoFactory* automat = static_cast<CAutoFactory*>(factory->GetAuto()); + if(automat == nullptr) { + exception = ERR_GENERIC; + result->SetValInt(ERR_GENERIC); + CLogger::GetInstancePointer()->Error("in object.factory() - automat is nullptr"); + return false; + } + bool bEnable = false; if ( type == OBJECT_MOBILEwa ) |