Skip to content

Commit a375745

Browse files
author
Steve Hanson
committed
correct workaround for issue 1805
1 parent 7fee368 commit a375745

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

include/rapidjson/schema.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,8 +2106,9 @@ class GenericSchemaValidator :
21062106
error.AddMember(GetMissingString(), missingDependents_.Move(), GetStateAllocator());
21072107
AddErrorCode(error, code);
21082108
AddErrorInstanceLocation(error, false);
2109-
PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetStateAllocator());
2110-
AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetStateAllocator()));
2109+
// When appending to a pointer ensure its allocator is used
2110+
PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetInvalidSchemaPointer().GetAllocator());
2111+
AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetInvalidSchemaPointer().GetAllocator()));
21112112
ValueType wrapper(kObjectType);
21122113
wrapper.AddMember(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator()).Move(), error, GetStateAllocator());
21132114
currentError_.AddMember(ValueType(sourceName, GetStateAllocator()).Move(), wrapper, GetStateAllocator());

test/perftest/schematest.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ RAPIDJSON_DIAG_POP
5151

5252
class Schema : public PerfTest {
5353
public:
54-
typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
55-
5654
Schema() {}
5755

5856
virtual void SetUp() {
@@ -91,8 +89,6 @@ class Schema : public PerfTest {
9189

9290
char jsonBuffer[65536];
9391
MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));
94-
char schemaBuffer[65536];
95-
MemoryPoolAllocator<> schemaAllocator(schemaBuffer, sizeof(schemaBuffer));
9692

9793
for (size_t i = 0; i < ARRAY_SIZE(filenames); i++) {
9894
char filename[FILENAME_MAX];
@@ -116,7 +112,7 @@ class Schema : public PerfTest {
116112
continue;
117113

118114
TestSuite* ts = new TestSuite;
119-
ts->schema = new SchemaDocumentType((*schemaItr)["schema"], 0, 0, 0, &schemaAllocator);
115+
ts->schema = new SchemaDocument((*schemaItr)["schema"]);
120116

121117
const Value& tests = (*schemaItr)["tests"];
122118
for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {
@@ -191,7 +187,7 @@ class Schema : public PerfTest {
191187
for (DocumentList::iterator itr = tests.begin(); itr != tests.end(); ++itr)
192188
delete *itr;
193189
}
194-
SchemaDocumentType* schema;
190+
SchemaDocument* schema;
195191
DocumentList tests;
196192
};
197193

@@ -210,7 +206,7 @@ TEST_F(Schema, TestSuite) {
210206
for (int i = 0; i < trialCount; i++) {
211207
for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr) {
212208
const TestSuite& ts = **itr;
213-
GenericSchemaValidator<SchemaDocumentType, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
209+
GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
214210
for (DocumentList::const_iterator testItr = ts.tests.begin(); testItr != ts.tests.end(); ++testItr) {
215211
validator.Reset();
216212
(*testItr)->Accept(validator);

0 commit comments

Comments
 (0)