Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/CLR/Core/TypeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,16 @@ HRESULT CLR_RT_TypeDescriptor::InitializeFromObject(const CLR_RT_HeapBlock &ref)
{
obj = (CLR_RT_HeapBlock *)array->GetElement(obj->ArrayIndex());

// For reference arrays, if the element is null, we need to get the type from the array's element
// type rather than trying to dereference a null object
if (obj->Dereference() == nullptr)
{
// Use the array's element type.
// Keep 'reflex' null to avoid carrying array levels when returning an element type.
cls = &(array->ReflectionDataConst().data.type);
break;
}

NANOCLR_SET_AND_LEAVE(InitializeFromObject(*obj));
}

Expand Down