From 16bc1e811355ca2aa8137dec18e04d2c59f25def Mon Sep 17 00:00:00 2001 From: Max Charlamb Date: Wed, 29 Jan 2025 18:07:08 -0500 Subject: [PATCH] add interface check --- src/coreclr/vm/methodtablebuilder.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 60110263e4a274..32fc596eab54d5 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -3709,6 +3709,11 @@ BOOL MethodTableBuilder::IsSelfReferencingStaticValueTypeField(mdToken dwByV { STANDARD_VM_CONTRACT; + if(this->IsInterface()) + { + return TRUE; + } + if (dwByValueClassToken != this->GetCl()) { return FALSE; @@ -4042,7 +4047,7 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList, // By-value class BAD_FORMAT_NOTHROW_ASSERT(dwByValueClassToken != 0); - if (this->IsValueClass() && (pTokenModule == GetModule())) + if ((this->IsValueClass() || this->IsInterface()) && (pTokenModule == GetModule())) { if (TypeFromToken(dwByValueClassToken) == mdtTypeRef) { @@ -4101,7 +4106,7 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList, BuildMethodTableThrowException(IDS_CLASSLOAD_VALUEINSTANCEFIELD, mdMethodDefNil); } - if (!IsValueClass()) + if (!IsValueClass() && !IsInterface()) { BuildMethodTableThrowException(COR_E_BADIMAGEFORMAT, IDS_CLASSLOAD_MUST_BE_BYVAL, mdTokenNil); }