From 50032bc847a79dc209e6e1ae4dd77a2ec2d52be9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 13 Jan 2015 15:08:32 -0500 Subject: [PATCH] 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. --- Utilities/cmjsoncpp/src/lib_json/json_value.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Utilities/cmjsoncpp/src/lib_json/json_value.cpp b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp index 8f46d3b3f..478afe102 100644 --- a/Utilities/cmjsoncpp/src/lib_json/json_value.cpp +++ b/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_; }