]> granicus.if.org Git - icinga2/commitdiff
Fix: Operator + is inconsistent when used with empty and non-empty strings
authorGunnar Beutner <gunnar@beutner.name>
Sat, 1 Aug 2015 02:35:50 +0000 (04:35 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 1 Aug 2015 02:38:12 +0000 (04:38 +0200)
fixes #9806

lib/base/value-operators.cpp

index f53bbda6a10e28653bdeafa2961ceb293147c01c..46d50a5e21fd628cdcdf7ccb43102c04e35b8e06 100644 (file)
@@ -228,9 +228,9 @@ Value icinga::operator+(const String& lhs, const Value& rhs)
 
 Value icinga::operator+(const Value& lhs, const Value& rhs)
 {
-       if ((lhs.IsEmpty() || lhs.IsNumber()) && (rhs.IsEmpty() || rhs.IsNumber()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
+       if ((lhs.IsEmpty() || lhs.IsNumber()) && !lhs.IsString() && (rhs.IsEmpty() || rhs.IsNumber()) && !rhs.IsString() && !(lhs.IsEmpty() && rhs.IsEmpty()))
                return static_cast<double>(lhs) + static_cast<double>(rhs);
-       if ((lhs.IsString() || lhs.IsEmpty() || lhs.IsNumber()) && (rhs.IsString() || rhs.IsEmpty() || rhs.IsNumber()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
+       if ((lhs.IsString() || lhs.IsEmpty() || lhs.IsNumber()) && (rhs.IsString() || rhs.IsEmpty() || rhs.IsNumber()))
                return static_cast<String>(lhs) + static_cast<String>(rhs);
        else if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
                return static_cast<double>(lhs) + static_cast<double>(rhs);