diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 6d68002..2690084 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -196,15 +196,16 @@ void Value::CommentInfo::setComment(const char* text, size_t len) { Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {} Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate) - : cstr_(allocate == duplicate ? duplicateStringValue(str) : str) + : cstr_(str) { + // allocate != duplicate storage_.policy_ = allocate; storage_.length_ = length; } Value::CZString::CZString(const CZString& other) : cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0 - ? duplicateStringValue(other.cstr_) + ? duplicateStringValue(other.cstr_, other.storage_.length_) : other.cstr_) { storage_.policy_ = (other.cstr_ diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index c7d938e..c6be13d 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -1,3 +1,4 @@ +#include // Copyright 2007-2010 Baptiste Lepilleur // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. @@ -213,6 +214,31 @@ JSONTEST_FIXTURE(ValueTest, objects) { JSONTEST_ASSERT_EQUAL(false, did); } +JSONTEST_FIXTURE(ValueTest, nulls) { + static char const keyWithNulls[] = "key\0with\0nulls"; + std::string const strKeyWithNulls(keyWithNulls, sizeof keyWithNulls); + object1_[strKeyWithNulls] = "object1_[keyWithNulls]"; + Json::Value::Members f = object1_.getMemberNames(); + std::cout << "size:" << f.size() << "\n"; + for (int i=0; i