From 23a4fb142978127d73aa46b5893ebe3aba903587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Tue, 2 Feb 2021 18:40:54 +0100 Subject: [PATCH] Add missing null check to SGLight's dim-factor expression --- simgear/scene/model/SGLight.cxx | 12 +++++++----- simgear/scene/model/SGLightAnimation.cxx | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/simgear/scene/model/SGLight.cxx b/simgear/scene/model/SGLight.cxx index 47a48ef1..93967c0f 100644 --- a/simgear/scene/model/SGLight.cxx +++ b/simgear/scene/model/SGLight.cxx @@ -123,11 +123,13 @@ SGLight::appendLight(const SGPropertyNode *configNode, if (dim_factor) { const SGExpressiond *expression = read_value(dim_factor, modelRoot, "", 0, 1); - light->setUpdateCallback( - new SGLight::UpdateCallback(expression, - light->getAmbient(), - light->getDiffuse(), - light->getSpecular())); + if (expression) { + light->setUpdateCallback( + new SGLight::UpdateCallback(expression, + light->getAmbient(), + light->getDiffuse(), + light->getSpecular())); + } } osg::Shape *debug_shape = nullptr; diff --git a/simgear/scene/model/SGLightAnimation.cxx b/simgear/scene/model/SGLightAnimation.cxx index c9a4ef71..961fa4b1 100644 --- a/simgear/scene/model/SGLightAnimation.cxx +++ b/simgear/scene/model/SGLightAnimation.cxx @@ -56,11 +56,13 @@ SGLightAnimation::SGLightAnimation(simgear::SGTransientModelData &modelData) : if (dim_factor) { const SGExpressiond *expression = read_value(dim_factor, modelData.getModelRoot(), "", 0, 1); - light->setUpdateCallback( - new SGLight::UpdateCallback(expression, - light->getAmbient(), - light->getDiffuse(), - light->getSpecular())); + if (expression) { + light->setUpdateCallback( + new SGLight::UpdateCallback(expression, + light->getAmbient(), + light->getDiffuse(), + light->getSpecular())); + } } align->setName(getConfig()->getStringValue("name"));