Skip to content

Commit

Permalink
small corrections for schema.h
Browse files Browse the repository at this point in the history
  • Loading branch information
smhdfdl authored and miloyip committed Nov 30, 2022
1 parent 97fd830 commit 80b6d1c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/rapidjson/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class Schema {
Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator, const UriType& id = UriType()) :
allocator_(allocator),
uri_(schemaDocument->GetURI(), *allocator),
id_(id),
id_(id, allocator),
pointer_(p, allocator),
typeless_(schemaDocument->GetTypeless()),
enum_(),
Expand Down Expand Up @@ -1614,7 +1614,7 @@ class IGenericRemoteSchemaDocumentProvider {

virtual ~IGenericRemoteSchemaDocumentProvider() {}
virtual const SchemaDocumentType* GetRemoteDocument(const Ch* uri, SizeType length) = 0;
virtual const SchemaDocumentType* GetRemoteDocument(GenericUri<ValueType, AllocatorType> uri) { return GetRemoteDocument(uri.GetBaseString(), uri.GetBaseStringLength()); }
virtual const SchemaDocumentType* GetRemoteDocument(const GenericUri<ValueType, AllocatorType> uri) { return GetRemoteDocument(uri.GetBaseString(), uri.GetBaseStringLength()); }
};

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1712,7 +1712,7 @@ class GenericSchemaDocument {
schemaMap_(std::move(rhs.schemaMap_)),
schemaRef_(std::move(rhs.schemaRef_)),
uri_(std::move(rhs.uri_)),
docId_(rhs.docId_),
docId_(std::move(rhs.docId_)),
error_(std::move(rhs.error_)),
currentError_(std::move(rhs.currentError_))
{
Expand All @@ -1733,6 +1733,7 @@ class GenericSchemaDocument {
Allocator::Free(typeless_);
}

// these may contain some allocator data so clear before deleting ownAllocator_
uri_.SetNull();
error_.SetNull();
currentError_.SetNull();
Expand Down Expand Up @@ -1960,7 +1961,7 @@ class GenericSchemaDocument {
// Get the subschema
if (const ValueType *pv = relPointer.Get(*base)) {
// Now get the absolute JSON pointer by adding relative to base
PointerType pointer(basePointer);
PointerType pointer(basePointer, allocator_);
for (SizeType i = 0; i < relPointer.GetTokenCount(); i++)
pointer = pointer.Append(relPointer.GetTokens()[i], allocator_);
if (IsCyclicRef(pointer))
Expand All @@ -1978,7 +1979,7 @@ class GenericSchemaDocument {
}
} else {
// Plain name fragment, relative to the resolved URI
PointerType pointer = PointerType();
PointerType pointer(allocator_);
// See if the fragment matches an id in this document.
// Search from the base we just established. Returns the subschema in the document and its absolute JSON pointer.
if (const ValueType *pv = FindId(*base, ref, pointer, UriType(ref.GetBaseString(), ref.GetBaseStringLength(), allocator_), true, basePointer)) {
Expand Down

0 comments on commit 80b6d1c

Please sign in to comment.