From 13595ce05db1eca106dae5a9e1644c83fb2a4c09 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 4 Feb 2022 12:07:24 +0000 Subject: [PATCH] Throw exception for broken XML animations. Throwing an exception causes normal error-collecting to trigger for the XML model load, so this is sufficient to avoid the crash and also report back to the aircraft developer & user. Thanks to Michael Danilov for catching this. SF-ID: https://sourceforge.net/p/flightgear/codetickets/2702/ --- simgear/scene/model/animation.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index 76f691ad..0ff96a2c 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -965,6 +965,9 @@ SGTranslateAnimation::SGTranslateAnimation(simgear::SGTransientModelData &modelD SGSharedPtr value; value = read_value(modelData.getConfigNode(), modelData.getModelRoot(), "-m", -SGLimitsd::max(), SGLimitsd::max()); + if (!value) { + throw sg_format_exception("Invalid translate expression", "Value is not readable"); + } _animationValue = value->simplify(); if (_animationValue) _initialValue = _animationValue->getValue(); @@ -1191,6 +1194,9 @@ SGRotateAnimation::SGRotateAnimation(simgear::SGTransientModelData &modelData) : SGSharedPtr value; value = read_value(modelData.getConfigNode(), modelData.getModelRoot(), "-deg", -SGLimitsd::max(), SGLimitsd::max()); + if (!value) { + throw sg_format_exception("Invalid rotate expression", "INvalid value"); + } _animationValue = value->simplify(); if (_animationValue) _initialValue = _animationValue->getValue(); @@ -2037,6 +2043,9 @@ public: SGBlendAnimation::SGBlendAnimation(simgear::SGTransientModelData &modelData) : SGAnimation(modelData), _animationValue(read_value(modelData.getConfigNode(), modelData.getModelRoot(), "", 0, 1)) { + if (!_animationValue) { + throw sg_format_exception("Invalid blend expression", "Invalid value"); + } } osg::Group*