From 899156172d80b809131e22aaae535f2033fd8b6f Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 1 Jul 2016 06:40:24 -0700 Subject: [PATCH] Make GenericSchemaDocument constructor explicit Prior to this change, a user could incorrectly pass a Document object to SchemaValidator. This would implicitly construct a SchemaDocument, which would then be destructed before the validator was used. This caused unpredictable results including memory corruption and program crashes. --- include/rapidjson/schema.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 4c1eacbbf..b182aa27f 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -1338,7 +1338,7 @@ class GenericSchemaDocument { \param remoteProvider An optional remote schema document provider for resolving remote reference. Can be null. \param allocator An optional allocator instance for allocating memory. Can be null. */ - GenericSchemaDocument(const ValueType& document, IRemoteSchemaDocumentProviderType* remoteProvider = 0, Allocator* allocator = 0) : + explicit GenericSchemaDocument(const ValueType& document, IRemoteSchemaDocumentProviderType* remoteProvider = 0, Allocator* allocator = 0) : remoteProvider_(remoteProvider), allocator_(allocator), ownAllocator_(),