Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Hanson <smh@uk.ibm.com>2021-01-29 19:43:12 +0300
committerSteve Hanson <smh@uk.ibm.com>2021-01-29 19:43:12 +0300
commita3757456feb86fa6cd0ded48bbe1e32b8e814b54 (patch)
tree46d8e41dbc7b3c47d621fcaf56903cd756d61165
parent7fee368be3605ba18e6af692897f9b836a889cbb (diff)
correct workaround for issue 1805
-rw-r--r--include/rapidjson/schema.h5
-rw-r--r--test/perftest/schematest.cpp10
2 files changed, 6 insertions, 9 deletions
diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h
index 2b356212..11f71609 100644
--- a/include/rapidjson/schema.h
+++ b/include/rapidjson/schema.h
@@ -2106,8 +2106,9 @@ public:
error.AddMember(GetMissingString(), missingDependents_.Move(), GetStateAllocator());
AddErrorCode(error, code);
AddErrorInstanceLocation(error, false);
- PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetStateAllocator());
- AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetStateAllocator()));
+ // When appending to a pointer ensure its allocator is used
+ PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetInvalidSchemaPointer().GetAllocator());
+ AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetInvalidSchemaPointer().GetAllocator()));
ValueType wrapper(kObjectType);
wrapper.AddMember(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator()).Move(), error, GetStateAllocator());
currentError_.AddMember(ValueType(sourceName, GetStateAllocator()).Move(), wrapper, GetStateAllocator());
diff --git a/test/perftest/schematest.cpp b/test/perftest/schematest.cpp
index 82377449..cdc7fda1 100644
--- a/test/perftest/schematest.cpp
+++ b/test/perftest/schematest.cpp
@@ -51,8 +51,6 @@ RAPIDJSON_DIAG_POP
class Schema : public PerfTest {
public:
- typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
-
Schema() {}
virtual void SetUp() {
@@ -91,8 +89,6 @@ public:
char jsonBuffer[65536];
MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));
- char schemaBuffer[65536];
- MemoryPoolAllocator<> schemaAllocator(schemaBuffer, sizeof(schemaBuffer));
for (size_t i = 0; i < ARRAY_SIZE(filenames); i++) {
char filename[FILENAME_MAX];
@@ -116,7 +112,7 @@ public:
continue;
TestSuite* ts = new TestSuite;
- ts->schema = new SchemaDocumentType((*schemaItr)["schema"], 0, 0, 0, &schemaAllocator);
+ ts->schema = new SchemaDocument((*schemaItr)["schema"]);
const Value& tests = (*schemaItr)["tests"];
for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {
@@ -191,7 +187,7 @@ protected:
for (DocumentList::iterator itr = tests.begin(); itr != tests.end(); ++itr)
delete *itr;
}
- SchemaDocumentType* schema;
+ SchemaDocument* schema;
DocumentList tests;
};
@@ -210,7 +206,7 @@ TEST_F(Schema, TestSuite) {
for (int i = 0; i < trialCount; i++) {
for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr) {
const TestSuite& ts = **itr;
- GenericSchemaValidator<SchemaDocumentType, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
+ GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
for (DocumentList::const_iterator testItr = ts.tests.begin(); testItr != ts.tests.end(); ++testItr) {
validator.Reset();
(*testItr)->Accept(validator);