@@ -380,13 +380,19 @@ struct SchemaValidationContext {
380
380
if (hasher)
381
381
factory.DestroryHasher (hasher);
382
382
if (validators) {
383
- for (SizeType i = 0 ; i < validatorCount; i++)
384
- factory.DestroySchemaValidator (validators[i]);
383
+ for (SizeType i = 0 ; i < validatorCount; i++) {
384
+ if (validators[i]) {
385
+ factory.DestroySchemaValidator (validators[i]);
386
+ }
387
+ }
385
388
factory.FreeState (validators);
386
389
}
387
390
if (patternPropertiesValidators) {
388
- for (SizeType i = 0 ; i < patternPropertiesValidatorCount; i++)
389
- factory.DestroySchemaValidator (patternPropertiesValidators[i]);
391
+ for (SizeType i = 0 ; i < patternPropertiesValidatorCount; i++) {
392
+ if (patternPropertiesValidators[i]) {
393
+ factory.DestroySchemaValidator (patternPropertiesValidators[i]);
394
+ }
395
+ }
390
396
factory.FreeState (patternPropertiesValidators);
391
397
}
392
398
if (patternPropertiesSchemas)
@@ -1301,6 +1307,7 @@ class Schema {
1301
1307
if (validatorCount_) {
1302
1308
RAPIDJSON_ASSERT (context.validators == 0 );
1303
1309
context.validators = static_cast <ISchemaValidator**>(context.factory .MallocState (sizeof (ISchemaValidator*) * validatorCount_));
1310
+ std::memset (context.validators , 0 , sizeof (ISchemaValidator*) * validatorCount_);
1304
1311
context.validatorCount = validatorCount_;
1305
1312
1306
1313
// Always return after first failure for these sub-validators
@@ -2544,6 +2551,7 @@ RAPIDJSON_MULTILINEMACRO_END
2544
2551
ISchemaValidator**& va = CurrentContext ().patternPropertiesValidators ;
2545
2552
SizeType& validatorCount = CurrentContext ().patternPropertiesValidatorCount ;
2546
2553
va = static_cast <ISchemaValidator**>(MallocState (sizeof (ISchemaValidator*) * count));
2554
+ std::memset (va, 0 , sizeof (ISchemaValidator*) * count);
2547
2555
for (SizeType i = 0 ; i < count; i++)
2548
2556
va[validatorCount++] = CreateSchemaValidator (*sa[i], true ); // Inherit continueOnError
2549
2557
}
0 commit comments