]> granicus.if.org Git - icinga2/commitdiff
Fix operator shared_ptr<T> for the Value class
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 5 Nov 2014 15:09:22 +0000 (16:09 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 5 Nov 2014 15:09:22 +0000 (16:09 +0100)
fixes #7586

lib/base/value.hpp

index 7a069c963267062ab972f947b4245114fdf01c9f..12885cbfefe1bbf6686fd1810129315782bcd7ac 100644 (file)
@@ -99,12 +99,17 @@ public:
                if (IsEmpty())
                        return shared_ptr<T>();
 
-               shared_ptr<T> object = dynamic_pointer_cast<T>(boost::get<Object::Ptr>(m_Value));
+               Object::Ptr object = boost::get<Object::Ptr>(m_Value);
 
                if (!object)
+                       return shared_ptr<T>();
+
+               shared_ptr<T> tobject = dynamic_pointer_cast<T>(object);
+
+               if (!tobject)
                        BOOST_THROW_EXCEPTION(std::bad_cast());
 
-               return object;
+               return tobject;
        }
 
        bool IsEmpty(void) const;