diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index ef5b301..a059429 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -801,6 +801,9 @@ public: } private: + // Prohibit assignment + GenericDocument& operator=(const GenericDocument&); + void ClearStack() { if (Allocator::kNeedFree) while (stack_.GetSize() > 0) // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects) diff --git a/test/unittest/documenttest.cpp b/test/unittest/documenttest.cpp index 5dd4f35..82fc67d 100644 --- a/test/unittest/documenttest.cpp +++ b/test/unittest/documenttest.cpp @@ -82,3 +82,11 @@ TEST(Document, UTF16_Document) { EXPECT_EQ(0, wcscmp(L"Wed Oct 30 17:13:20 +0000 2012", s.GetString())); } + +// Issue 22: Memory corruption via operator= +// Fixed by making unimplemented assignment operator private. +//TEST(Document, Assignment) { +// Document d1; +// Document d2; +// d1 = d2; +//}