From 1f253f7fc8b767281ced2b624e10fed22ae9f8eb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 27 May 2014 00:16:40 -0400 Subject: [PATCH] Variant - ::operator_partial should fail for strings if either operand is of zero length. --- src/Variant.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Variant.cpp b/src/Variant.cpp index 79bdc52ad..f343d7642 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -764,7 +764,13 @@ bool Variant::operator_partial (const Variant& other) const // Why the "if" instead of "min"? This is an attempt to eliminate one // std::string::substr call. int left_length = left._string.length (); + if (left_length == 0) + return false; + int right_length = right._string.length (); + if (right_length == 0) + return false; + if (left_length < right_length) return left._string == right._string.substr (0, left_length); else