Browse Source

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.
Brad King 11 years ago
parent
commit
50032bc847
1 changed files with 6 additions and 2 deletions
  1. 6 2
      Utilities/cmjsoncpp/src/lib_json/json_value.cpp

+ 6 - 2
Utilities/cmjsoncpp/src/lib_json/json_value.cpp

@@ -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_;
 }