Skip to content

Commit 046c65c

Browse files
committed
fix build
1 parent f49d547 commit 046c65c

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

include/json/value.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
#include <string>
5151
#include <vector>
5252

53+
// Forward declaration for testing.
54+
struct ValueTest;
55+
5356
#ifdef JSONCPP_HAS_STRING_VIEW
5457
#include <string_view>
5558
#endif
@@ -201,6 +204,7 @@ class JSON_API StaticString {
201204
*/
202205
class JSON_API Value {
203206
friend class ValueIteratorBase;
207+
friend struct ::ValueTest;
204208

205209
public:
206210
using Members = std::vector<String>;

src/lib_json/json_value.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ Value::CZString& Value::CZString::operator=(const CZString& other) {
301301
}
302302

303303
Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
304+
if (cstr_ && storage_.policy_ == duplicate) {
305+
releasePrefixedStringValue(const_cast<char*>(cstr_));
306+
}
304307
cstr_ = other.cstr_;
305308
if (other.cstr_) {
306309
storage_.policy_ = other.storage_.policy_;

0 commit comments

Comments
 (0)