avoid reference to null pointer and member access within null pointer
UBSAN gave issues with the typeless Schema: runtime error: reference binding to null pointer of type 'rapidjson::GenericSchemaDocument<rapidjson::GenericValue<rapidjson::UTF16<wchar_t>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >, rapidjson::CrtAllocator>' and runtime error: member access within null pointer of type 'AllocatorType' (aka 'rapidjson::CrtAllocator')
This commit is contained in:
parent
fe550f3866
commit
8074b722f0
@ -413,9 +413,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document);
|
||||
AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document);
|
||||
AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document);
|
||||
if (schemaDocument) {
|
||||
AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document);
|
||||
AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document);
|
||||
AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document);
|
||||
}
|
||||
|
||||
if (const ValueType* v = GetMember(value, GetNotString())) {
|
||||
schemaDocument->CreateSchema(¬_, p.Append(GetNotString(), allocator_), *v, document);
|
||||
@ -578,7 +580,9 @@ public:
|
||||
}
|
||||
|
||||
~Schema() {
|
||||
allocator_->Free(enum_);
|
||||
if (allocator_) {
|
||||
allocator_->Free(enum_);
|
||||
}
|
||||
if (properties_) {
|
||||
for (SizeType i = 0; i < propertyCount_; i++)
|
||||
properties_[i].~Property();
|
||||
|
Loading…
x
Reference in New Issue
Block a user