@@ -163,9 +163,9 @@ void Value::CommentInfo::setComment(const char* text, size_t len) {
163163
164164Value::CZString::CZString (ArrayIndex index) : cstr_(0 ), index_(index) {}
165165
166- Value::CZString::CZString (const char * cstr , DuplicationPolicy allocate)
167- : cstr_(allocate == duplicate ? duplicateStringValue(cstr ) : cstr ),
168- storage_ ({allocate, 0 })
166+ Value::CZString::CZString (char const * str, unsigned length , DuplicationPolicy allocate)
167+ : cstr_(allocate == duplicate ? duplicateStringValue(str ) : str ),
168+ storage_ ({allocate, length })
169169{}
170170
171171Value::CZString::CZString (const CZString& other)
@@ -175,7 +175,7 @@ Value::CZString::CZString(const CZString& other)
175175 storage_({(other.cstr_
176176 ? (other.storage_ .policy_ == noDuplication
177177 ? noDuplication : duplicate)
178- : other.storage_ .policy_ ), 0 })
178+ : other.storage_ .policy_ ), other. storage_ . length_ })
179179{}
180180
181181Value::CZString::~CZString () {
@@ -849,7 +849,7 @@ Value& Value::resolveReference(const char* key, bool isStatic) {
849849 if (type_ == nullValue)
850850 *this = Value (objectValue);
851851 CZString actualKey (
852- key, isStatic ? CZString::noDuplication : CZString::duplicateOnCopy);
852+ key, strlen (key), isStatic ? CZString::noDuplication : CZString::duplicateOnCopy);
853853 ObjectValues::iterator it = value_.map_ ->lower_bound (actualKey);
854854 if (it != value_.map_ ->end () && (*it).first == actualKey)
855855 return (*it).second ;
@@ -873,7 +873,7 @@ const Value& Value::operator[](const char* key) const {
873873 " in Json::Value::operator[](char const*)const: requires objectValue" );
874874 if (type_ == nullValue)
875875 return null;
876- CZString actualKey (key, CZString::noDuplication);
876+ CZString actualKey (key, strlen (key), CZString::noDuplication);
877877 ObjectValues::const_iterator it = value_.map_ ->find (actualKey);
878878 if (it == value_.map_ ->end ())
879879 return null;
@@ -918,7 +918,7 @@ bool Value::removeMember(const char* key, Value* removed) {
918918 if (type_ != objectValue) {
919919 return false ;
920920 }
921- CZString actualKey (key, CZString::noDuplication);
921+ CZString actualKey (key, strlen (key), CZString::noDuplication);
922922 ObjectValues::iterator it = value_.map_ ->find (actualKey);
923923 if (it == value_.map_ ->end ())
924924 return false ;
0 commit comments