diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 5e125b8..a72ace9 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -1550,7 +1550,6 @@ public: , depth_(0) #endif { - CreateOwnAllocator(); } //! Constructor with output handler. @@ -1579,7 +1578,6 @@ public: , depth_(0) #endif { - CreateOwnAllocator(); } //! Destructor. @@ -1592,7 +1590,7 @@ public: void Reset() { while (!schemaStack_.Empty()) PopSchema(); - //documentStack_.Clear(); + documentStack_.Clear(); valid_ = true; } @@ -1615,10 +1613,6 @@ public: return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom(), documentStack_.GetSize() / sizeof(Ch)); } - StateAllocator& GetStateAllocator() { - return *stateAllocator_; - } - #if RAPIDJSON_SCHEMA_VERBOSE #define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \ RAPIDJSON_MULTILINEMACRO_BEGIN\ @@ -1774,12 +1768,12 @@ private: , depth_(depth) #endif { - CreateOwnAllocator(); } - void CreateOwnAllocator() { + StateAllocator& GetStateAllocator() { if (!stateAllocator_) stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator()); + return *stateAllocator_; } bool BeginValue() { diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index 3d4bb50..623c65a 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -1148,6 +1148,8 @@ TEST(SchemaValidatingWriter, Simple) { d.Parse("\"ABCD\""); EXPECT_FALSE(d.Accept(validator)); EXPECT_FALSE(validator.IsValid()); + EXPECT_TRUE(validator.GetInvalidSchemaPointer() == SchemaDocument::PointerType("")); + EXPECT_TRUE(validator.GetInvalidDocumentPointer() == SchemaDocument::PointerType("")); } #ifdef __clang__