Makes StringEqual()
more safe by always compares lengths.
This commit is contained in:
parent
71ae5660ed
commit
afe59a0db1
@ -1281,8 +1281,9 @@ private:
|
|||||||
bool StringEqual(const GenericValue& rhs) const {
|
bool StringEqual(const GenericValue& rhs) const {
|
||||||
RAPIDJSON_ASSERT(IsString());
|
RAPIDJSON_ASSERT(IsString());
|
||||||
RAPIDJSON_ASSERT(rhs.IsString());
|
RAPIDJSON_ASSERT(rhs.IsString());
|
||||||
return data_.s.str == rhs.data_.s.str || // fast path for constant string
|
return data_.s.length == rhs.data_.s.length &&
|
||||||
((data_.s.length == rhs.data_.s.length) && memcmp(data_.s.str, rhs.data_.s.str, sizeof(Ch) * data_.s.length) == 0);
|
(data_.s.str == rhs.data_.s.str // fast path for constant string
|
||||||
|
|| memcmp(data_.s.str, rhs.data_.s.str, sizeof(Ch) * data_.s.length) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Data data_;
|
Data data_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user