Skip to content

Commit e0c3cad

Browse files
authored
Add support to process null in attributes (#3190)
1 parent 38faac2 commit e0c3cad

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/CLR/Core/TypeSystem.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7183,10 +7183,22 @@ HRESULT CLR_RT_AttributeParser::ReadString(CLR_RT_HeapBlock *&value)
71837183

71847184
NANOCLR_READ_UNALIGNED_UINT16(tk, m_blob);
71857185

7186-
NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(*value, CLR_TkFromType(TBL_Strings, tk), m_assm));
7186+
// check for invalid string ID (0xFFFF) meaning "null"
7187+
if (tk == 0xFFFF)
7188+
{
7189+
// create a string
7190+
NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(*value, nullptr, m_assm));
71877191

7188-
// need to box this
7189-
value->PerformBoxing(desc.m_handlerCls);
7192+
// null the object so it's a real null
7193+
value->SetObjectReference(nullptr);
7194+
}
7195+
else
7196+
{
7197+
NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(*value, CLR_TkFromType(TBL_Strings, tk), m_assm));
7198+
7199+
// need to box this
7200+
value->PerformBoxing(desc.m_handlerCls);
7201+
}
71907202

71917203
NANOCLR_NOCLEANUP();
71927204
}

0 commit comments

Comments
 (0)