mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Variant
- ::operator_partial should fail for strings if either operand is of zero length.
This commit is contained in:
parent
3c72e87d70
commit
1f253f7fc8
1 changed files with 6 additions and 0 deletions
|
@ -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
|
// Why the "if" instead of "min"? This is an attempt to eliminate one
|
||||||
// std::string::substr call.
|
// std::string::substr call.
|
||||||
int left_length = left._string.length ();
|
int left_length = left._string.length ();
|
||||||
|
if (left_length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
int right_length = right._string.length ();
|
int right_length = right._string.length ();
|
||||||
|
if (right_length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (left_length < right_length)
|
if (left_length < right_length)
|
||||||
return left._string == right._string.substr (0, left_length);
|
return left._string == right._string.substr (0, left_length);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue