From dec1225c07abf824366b1e62f8687f2aa3f765c4 Mon Sep 17 00:00:00 2001 From: miloyip Date: Fri, 8 May 2015 15:07:31 +0800 Subject: [PATCH] Fix warning and runtime delete error. --- include/rapidjson/schema.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 1851f5e..aa65bf2 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -106,7 +106,7 @@ struct SchemaValidationContext { ~SchemaValidationContext() { delete notValidator; - delete patternPropertiesSchemas; + delete[] patternPropertiesSchemas; delete[] objectDependencies; } @@ -392,20 +392,16 @@ public: break; } - switch (context.objectPatternValidatorType) { - case kPatternValidatorOnly: + if (context.objectPatternValidatorType == kPatternValidatorOnly) { if (!patternValid) return false; - break; - case kPatternValidatorWithProperty: + } + else if (context.objectPatternValidatorType == kPatternValidatorWithProperty) { if (!patternValid || !otherValid) return false; - break; - case kPatternValidatorWithAdditionalProperty: - if (!patternValid && !otherValid) - return false; - break; } + else if (!patternValid && !otherValid) // kPatternValidatorWithAdditionalProperty) + return false; } if (allOf_.schemas) @@ -529,7 +525,7 @@ public: std::memset(context.patternPropertiesSchemas, 0, sizeof(BaseSchema*) * count); } - return true; + return true; } bool Key(Context& context, const Ch* str, SizeType len, bool) const {