Make schema dtor robust against exceptions
This commit is contained in:
parent
781a4e667d
commit
dd3f730d74
@ -380,13 +380,19 @@ struct SchemaValidationContext {
|
|||||||
if (hasher)
|
if (hasher)
|
||||||
factory.DestroryHasher(hasher);
|
factory.DestroryHasher(hasher);
|
||||||
if (validators) {
|
if (validators) {
|
||||||
for (SizeType i = 0; i < validatorCount; i++)
|
for (SizeType i = 0; i < validatorCount; i++) {
|
||||||
factory.DestroySchemaValidator(validators[i]);
|
if (validators[i]) {
|
||||||
|
factory.DestroySchemaValidator(validators[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
factory.FreeState(validators);
|
factory.FreeState(validators);
|
||||||
}
|
}
|
||||||
if (patternPropertiesValidators) {
|
if (patternPropertiesValidators) {
|
||||||
for (SizeType i = 0; i < patternPropertiesValidatorCount; i++)
|
for (SizeType i = 0; i < patternPropertiesValidatorCount; i++) {
|
||||||
factory.DestroySchemaValidator(patternPropertiesValidators[i]);
|
if (patternPropertiesValidators[i]) {
|
||||||
|
factory.DestroySchemaValidator(patternPropertiesValidators[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
factory.FreeState(patternPropertiesValidators);
|
factory.FreeState(patternPropertiesValidators);
|
||||||
}
|
}
|
||||||
if (patternPropertiesSchemas)
|
if (patternPropertiesSchemas)
|
||||||
@ -1301,6 +1307,7 @@ private:
|
|||||||
if (validatorCount_) {
|
if (validatorCount_) {
|
||||||
RAPIDJSON_ASSERT(context.validators == 0);
|
RAPIDJSON_ASSERT(context.validators == 0);
|
||||||
context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));
|
context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));
|
||||||
|
std::memset(context.validators, 0, sizeof(ISchemaValidator*) * validatorCount_);
|
||||||
context.validatorCount = validatorCount_;
|
context.validatorCount = validatorCount_;
|
||||||
|
|
||||||
// Always return after first failure for these sub-validators
|
// Always return after first failure for these sub-validators
|
||||||
@ -2544,6 +2551,7 @@ private:
|
|||||||
ISchemaValidator**& va = CurrentContext().patternPropertiesValidators;
|
ISchemaValidator**& va = CurrentContext().patternPropertiesValidators;
|
||||||
SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount;
|
SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount;
|
||||||
va = static_cast<ISchemaValidator**>(MallocState(sizeof(ISchemaValidator*) * count));
|
va = static_cast<ISchemaValidator**>(MallocState(sizeof(ISchemaValidator*) * count));
|
||||||
|
std::memset(va, 0, sizeof(ISchemaValidator*) * count);
|
||||||
for (SizeType i = 0; i < count; i++)
|
for (SizeType i = 0; i < count; i++)
|
||||||
va[validatorCount++] = CreateSchemaValidator(*sa[i], true); // Inherit continueOnError
|
va[validatorCount++] = CreateSchemaValidator(*sa[i], true); // Inherit continueOnError
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user