From e683b5fdec3d0ca58b11766085829970e9e22bf4 Mon Sep 17 00:00:00 2001 From: timoore Date: Mon, 10 Dec 2007 08:30:43 +0000 Subject: [PATCH] Check for null options before changing path in registry --- simgear/scene/model/ModelRegistry.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index 6ae694b8..0ac69685 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -204,8 +204,12 @@ public: struct OptionsPusher { FilePathList localPathList; - OptionsPusher(const ReaderWriter::Options* options) + bool validOptions; + OptionsPusher(const ReaderWriter::Options* options): + validOptions(false) { + if (!options) + return; Registry* registry = Registry::instance(); localPathList = registry->getDataFilePathList(); const FilePathList& regPathList = registry->getDataFilePathList(); @@ -219,11 +223,13 @@ struct OptionsPusher { } // Save the current Registry path list and install the augmented one. localPathList.swap(registry->getDataFilePathList()); + validOptions = true; } ~OptionsPusher() { // Restore the old path list - localPathList.swap(Registry::instance()->getDataFilePathList()); + if (validOptions) + localPathList.swap(Registry::instance()->getDataFilePathList()); } }; } // namespace -- 2.39.5