Skip to content

Commit c5a9177

Browse files
committed
Fix attribute enumerator
- Advance now checks not only table but also owner index for a full match. - Method index is now parsed from compressed token format.
1 parent b6e028d commit c5a9177

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/CLR/Core/TypeSystem.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6371,19 +6371,21 @@ bool CLR_RT_AttributeEnumerator::Advance()
63716371
ptr++;
63726372
num--;
63736373

6374-
if (ptr->Key() == key)
6374+
if (ptr->Key() == key && ptr->ownerIndex == m_data.ownerIndex)
63756375
{
6376-
CLR_INDEX tk = ptr->constructor;
6377-
// check TYPEDEF
6378-
if (tk & 0x8000)
6379-
{
6380-
m_match = m_assm->crossReferenceMethodRef[tk & 0x7FFF].target;
6381-
}
6382-
else
6376+
// get the token of the constructor (compressed format)
6377+
CLR_UINT32 token = CLR_UncompressMethodToken(ptr->constructor);
6378+
6379+
// get the method definition, by resolving the token
6380+
CLR_RT_MethodDef_Instance method{};
6381+
if (method.ResolveToken(token, m_assm) == false)
63836382
{
6384-
m_match.Set(m_assm->assemblyIndex, tk);
6383+
ASSERT(0);
63856384
}
63866385

6386+
// get the method definition index
6387+
m_match.data = method.data;
6388+
63876389
m_blob = m_assm->GetSignature(ptr->data);
63886390

63896391
fRes = true;

0 commit comments

Comments
 (0)