summaryrefslogtreecommitdiffstats
path: root/src/script/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/script.cpp')
-rw-r--r--src/script/script.cpp15
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 )