Commit df6362d4 authored by Milo Yip's avatar Milo Yip

Fix patternProperties & additionalProperties lead to ASSERT

Fix #825
parent 342a616a
...@@ -783,8 +783,10 @@ public: ...@@ -783,8 +783,10 @@ public:
if (patternProperties_) { if (patternProperties_) {
context.patternPropertiesSchemaCount = 0; context.patternPropertiesSchemaCount = 0;
for (SizeType i = 0; i < patternPropertyCount_; i++) for (SizeType i = 0; i < patternPropertyCount_; i++)
if (patternProperties_[i].pattern && IsPatternMatch(patternProperties_[i].pattern, str, len)) if (patternProperties_[i].pattern && IsPatternMatch(patternProperties_[i].pattern, str, len)) {
context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = patternProperties_[i].schema; context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = patternProperties_[i].schema;
context.valueSchema = typeless_;
}
} }
SizeType index; SizeType index;
......
...@@ -1322,6 +1322,13 @@ TEST(SchemaValidator, Issue728_AllOfRef) { ...@@ -1322,6 +1322,13 @@ TEST(SchemaValidator, Issue728_AllOfRef) {
VALIDATE(s, "{\"key1\": \"abc\", \"key2\": \"def\"}", true); VALIDATE(s, "{\"key1\": \"abc\", \"key2\": \"def\"}", true);
} }
TEST(SchemaValidator, Issue825) {
Document sd;
sd.Parse("{\"type\": \"object\", \"additionalProperties\": false, \"patternProperties\": {\"^i\": { \"type\": \"string\" } } }");
SchemaDocument s(sd);
VALIDATE(s, "{ \"item\": \"hello\" }", true);
}
#ifdef __clang__ #ifdef __clang__
RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_POP
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment