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:
Brad King 2015-01-13 15:08:32 -05:00
parent ad94b0521e
commit 50032bc847
1 changed files with 6 additions and 2 deletions

View File

@ -195,14 +195,18 @@ Value::CZString& Value::CZString::operator=(CZString other) {
}
bool Value::CZString::operator<(const CZString& other) const {
if (cstr_)
if (cstr_) {
assert(other.cstr_);
return strcmp(cstr_, other.cstr_) < 0;
}
return index_ < other.index_;
}
bool Value::CZString::operator==(const CZString& other) const {
if (cstr_)
if (cstr_) {
assert(other.cstr_);
return strcmp(cstr_, other.cstr_) == 0;
}
return index_ == other.index_;
}