Skip to content

Commit

Permalink
Make GenericSchemaDocument constructor explicit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjasonsmith committed Jul 1, 2016
1 parent 727e2b9 commit 8991561
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/rapidjson/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_(),
Expand Down

0 comments on commit 8991561

Please sign in to comment.