jsoncpp: Add missing assert before strcmp in json_value.cpp
The strcmp function does not allow NULL pointers, so add an assert to tell Clang scan-build that the code does not expect a NULL pointer.
This commit is contained in:
parent
ad94b0521e
commit
50032bc847
|
@ -195,14 +195,18 @@ Value::CZString& Value::CZString::operator=(CZString other) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::CZString::operator<(const CZString& other) const {
|
bool Value::CZString::operator<(const CZString& other) const {
|
||||||
if (cstr_)
|
if (cstr_) {
|
||||||
|
assert(other.cstr_);
|
||||||
return strcmp(cstr_, other.cstr_) < 0;
|
return strcmp(cstr_, other.cstr_) < 0;
|
||||||
|
}
|
||||||
return index_ < other.index_;
|
return index_ < other.index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::CZString::operator==(const CZString& other) const {
|
bool Value::CZString::operator==(const CZString& other) const {
|
||||||
if (cstr_)
|
if (cstr_) {
|
||||||
|
assert(other.cstr_);
|
||||||
return strcmp(cstr_, other.cstr_) == 0;
|
return strcmp(cstr_, other.cstr_) == 0;
|
||||||
|
}
|
||||||
return index_ == other.index_;
|
return index_ == other.index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue