diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 288b93d..420db62 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -1366,6 +1366,9 @@ public: new (schemaMap_.template Push()) SchemaEntry(refEntry->source, const_cast(s), false, allocator_); } } + else if (refEntry->schema) + *refEntry->schema = SchemaType::GetTypeless(); + refEntry->~SchemaRefEntry(); } diff --git a/test/unittest/schematest.cpp b/test/unittest/schematest.cpp index 6a8b685..4780516 100644 --- a/test/unittest/schematest.cpp +++ b/test/unittest/schematest.cpp @@ -1308,6 +1308,14 @@ TEST(SchemaValidator, Issue608) { INVALIDATE(s, "{\"a\" : null, \"a\" : null}", "", "required", ""); } +// Fail to resolve $ref in allOf causes crash in SchemaValidator::StartObject() +TEST(SchemaValidator, Issue728_AllOfRef) { + Document sd; + sd.Parse("{\"allOf\": [{\"$ref\": \"#/abc\"}]}"); + SchemaDocument s(sd); + VALIDATE(s, "{\"key1\": \"abc\", \"key2\": \"def\"}", true); +} + #ifdef __clang__ RAPIDJSON_DIAG_POP #endif