From 1ddab493e1a2b9e8149aa3a2123444e801550f83 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 20 Dec 2014 09:31:55 +0100 Subject: [PATCH] Make sure that Value::IsEmpty() returns true for empty strings fixes #8018 --- lib/base/value.hpp | 5 +---- lib/config/configtype.cpp | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/base/value.hpp b/lib/base/value.hpp index bb68acd4b..4f3984e8a 100644 --- a/lib/base/value.hpp +++ b/lib/base/value.hpp @@ -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 inline Value(const intrusive_ptr& 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(m_Value).IsEmpty())); } /** diff --git a/lib/config/configtype.cpp b/lib/config/configtype.cpp index bb9fe8f46..0a226af30 100644 --- a/lib/config/configtype.cpp +++ b/lib/config/configtype.cpp @@ -163,7 +163,7 @@ void ConfigType::ValidateObject(const Object::Ptr& object, Value value = VMOps::GetField(object, require); - if (value.IsEmpty() || (value.IsString() && static_cast(value).IsEmpty())) + if (value.IsEmpty()) BOOST_THROW_EXCEPTION(ScriptError("Required attribute is missing: " + LocationToString(locations))); locations.pop_back();