From 9ba892962c3ff0d4df428ae79d6176dc4879c50d Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Fri, 10 Apr 2015 23:46:13 +0200 Subject: [PATCH] Closedown crash prevention --- src/Cockpit/od_gauge.cxx | 6 ++++-- src/Scripting/NasalSys.cxx | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Cockpit/od_gauge.cxx b/src/Cockpit/od_gauge.cxx index 883a17178..dfb5617a3 100644 --- a/src/Cockpit/od_gauge.cxx +++ b/src/Cockpit/od_gauge.cxx @@ -127,8 +127,10 @@ class ReplaceStaticTextureVisitor: simgear::EffectGeode* eg = dynamic_cast(&node); if( !eg ) return; - - osg::StateSet* ss = eg->getEffect()->getDefaultStateSet(); + simgear::Effect* eff = eg->getEffect(); + if (!eff) + return; + osg::StateSet* ss = eff->getDefaultStateSet(); if( !ss ) return; diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index d37afa701..59a50867a 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -1165,7 +1165,9 @@ bool FGNasalSys::createModule(const char* moduleName, const char* fileName, naRef locals; naRef modname = naNewString(ctx); naStr_fromdata(modname, (char*)moduleName, strlen(moduleName)); - if(!naHash_get(_globals, modname, &locals)) + if (!((_globals).ref).ptr.obj) + return false; + if (!naHash_get(_globals, modname, &locals)) locals = naNewHash(ctx); _cmdArg = (SGPropertyNode*)cmdarg;