]> granicus.if.org Git - icinga2/commitdiff
Fix: Operator - should not work with "" and numbers
authorGunnar Beutner <gunnar@beutner.name>
Thu, 30 Jul 2015 18:01:08 +0000 (20:01 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 30 Jul 2015 18:01:08 +0000 (20:01 +0200)
fixes #9793

lib/base/value-operators.cpp

index 7c25188c729c3528e8cb8c97dded2d25bc92c9d7..f53bbda6a10e28653bdeafa2961ceb293147c01c 100644 (file)
@@ -275,7 +275,7 @@ Value icinga::operator+(int lhs, const Value& rhs)
 
 Value icinga::operator-(const Value& lhs, const Value& rhs)
 {
-       if ((lhs.IsNumber() || lhs.IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty()))
+       if ((lhs.IsNumber() || lhs.IsEmpty()) && !lhs.IsString() && (rhs.IsNumber() || rhs.IsEmpty()) && !rhs.IsString() && !(lhs.IsEmpty() && rhs.IsEmpty()))
                return static_cast<double>(lhs) - static_cast<double>(rhs);
        else if ((lhs.IsObjectType<Array>() || lhs.IsEmpty()) && (rhs.IsObjectType<Array>() || rhs.IsEmpty()) && !(lhs.IsEmpty() && rhs.IsEmpty())) {
                if (lhs.IsEmpty())