From 5c448687e14fb49d1f6828a74c5ee9781c8c5607 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Sat, 7 Mar 2015 13:33:16 -0600 Subject: [PATCH 1/3] fix ValueTest/zeroes* --- src/test_lib_json/main.cpp | 44 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) 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 Date: Sat, 7 Mar 2015 12:19:40 +0100 Subject: [PATCH 2/3] Trivial fixes in CZString constructors. --- src/lib_json/json_value.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 6d68002..e128eec 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -196,7 +196,7 @@ 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_(allocate == duplicate ? duplicateStringValue(str, length) : str) { storage_.policy_ = allocate; storage_.length_ = length; @@ -204,7 +204,7 @@ Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy al 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_ From a63d82d78acf028c5a8005a1419bcc0e744ed61a Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Sat, 7 Mar 2015 14:42:52 -0600 Subject: [PATCH 3/3] drop unused CString ctor case `Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate)` with `allocate == duplicate` does not happen. --- src/lib_json/json_value.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index e128eec..2690084 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -196,8 +196,9 @@ 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, length) : str) + : cstr_(str) { + // allocate != duplicate storage_.policy_ = allocate; storage_.length_ = length; }