]> granicus.if.org Git - icinga2/commitdiff
Make sure that Value::IsEmpty() returns true for empty strings
authorGunnar Beutner <gunnar@beutner.name>
Sat, 20 Dec 2014 08:31:55 +0000 (09:31 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 20 Dec 2014 08:31:55 +0000 (09:31 +0100)
fixes #8018

lib/base/value.hpp
lib/config/configtype.cpp

index bb68acd4b4af2c9dafaa61532e0fb82c1a252cda..4f3984e8a98db785ca23ed11c08b0b7e7cbc219b 100644 (file)
@@ -51,7 +51,6 @@ class I2_BASE_API Value
 {
 public:
        inline Value(void)
-               : m_Value()
        { }
 
        inline Value(int value)
@@ -91,7 +90,6 @@ public:
        { }
 
        inline Value(Object *value)
-               : m_Value()
        {
                if (!value)
                        return;
@@ -101,7 +99,6 @@ public:
 
        template<typename T>
        inline Value(const intrusive_ptr<T>& value)
-               : m_Value()
        {
                if (!value)
                        return;
@@ -160,7 +157,7 @@ public:
        */
        inline bool IsEmpty(void) const
        {
-               return (GetType() == ValueEmpty);
+               return (GetType() == ValueEmpty || (IsString() && boost::get<String>(m_Value).IsEmpty()));
        }
 
        /**
index bb9fe8f466853f14dd0ce8cb3e1ee2b3e406cfe0..0a226af30c634362c1a09da50b66f3be2b7edc24 100644 (file)
@@ -163,7 +163,7 @@ void ConfigType::ValidateObject(const Object::Ptr& object,
 
                        Value value = VMOps::GetField(object, require);
 
-                       if (value.IsEmpty() || (value.IsString() && static_cast<String>(value).IsEmpty()))
+                       if (value.IsEmpty())
                                BOOST_THROW_EXCEPTION(ScriptError("Required attribute is missing: " + LocationToString(locations)));
 
                        locations.pop_back();