From 504dfc1b99ef5e9dc30f7d49430196a618052946 Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Sat, 30 Jul 2022 09:00:07 -0700 Subject: [PATCH 1/2] Remove some undefined behavior --- src/coreclr/vm/methodtablebuilder.cpp | 18 +++++++++--------- src/coreclr/vm/methodtablebuilder.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 74479bf14c2294..9b33eaef6fc64b 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -258,8 +258,8 @@ MethodTableBuilder::LoaderFindMethodInParentClass( // and return the result to the caller. // We do this here to avoid recalculating pSubst. *pMethodConstraintsMatch = MetaSig::CompareMethodConstraints( - &methodSig.GetSubstitution(), methodSig.GetModule(), methodSig.GetToken(), - &entrySig.GetSubstitution(), entrySig.GetModule(), entrySig.GetToken()); + methodSig.GetSubstitution(), methodSig.GetModule(), methodSig.GetToken(), + entrySig.GetSubstitution(), entrySig.GetModule(), entrySig.GetToken()); } return pEntryMethod; @@ -869,8 +869,8 @@ MethodTableBuilder::MethodSignature::SignaturesEquivalent( STANDARD_VM_CONTRACT; return !!MetaSig::CompareMethodSigs( - sig1.GetSignature(), static_cast(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(), - sig2.GetSignature(), static_cast(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution(), + sig1.GetSignature(), static_cast(sig1.GetSignatureLength()), sig1.GetModule(), sig1.GetSubstitution(), + sig2.GetSignature(), static_cast(sig2.GetSignatureLength()), sig2.GetModule(), sig2.GetSubstitution(), allowCovariantReturn); } @@ -884,8 +884,8 @@ MethodTableBuilder::MethodSignature::SignaturesExactlyEqual( TokenPairList newVisited = TokenPairList::AdjustForTypeEquivalenceForbiddenScope(NULL); return !!MetaSig::CompareMethodSigs( - sig1.GetSignature(), static_cast(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(), - sig2.GetSignature(), static_cast(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution(), + sig1.GetSignature(), static_cast(sig1.GetSignatureLength()), sig1.GetModule(), sig1.GetSubstitution(), + sig2.GetSignature(), static_cast(sig2.GetSignatureLength()), sig2.GetModule(), sig2.GetSubstitution(), FALSE, &newVisited); } @@ -6257,8 +6257,8 @@ MethodTableBuilder::MethodImplCompareSignatures( } //now compare the method constraints - if (!MetaSig::CompareMethodConstraints(&implSig.GetSubstitution(), implSig.GetModule(), implSig.GetToken(), - &declSig.GetSubstitution(), declSig.GetModule(), declSig.GetToken())) + if (!MetaSig::CompareMethodConstraints(implSig.GetSubstitution(), implSig.GetModule(), implSig.GetToken(), + declSig.GetSubstitution(), declSig.GetModule(), declSig.GetToken())) { BuildMethodTableThrowException(dwConstraintErrorCode, implSig.GetToken()); } @@ -6599,7 +6599,7 @@ VOID MethodTableBuilder::PlaceInterfaceDeclarationOnClass( DispatchMapTypeID firstDispatchMapTypeID; ComputeDispatchMapTypeIDs( pDeclMT, - &pDecl->GetMethodSignature().GetSubstitution(), + pDecl->GetMethodSignature().GetSubstitution(), &firstDispatchMapTypeID, 1, &cInterfaceDuplicates); diff --git a/src/coreclr/vm/methodtablebuilder.h b/src/coreclr/vm/methodtablebuilder.h index 1d710db458d497..175fab114b53a7 100644 --- a/src/coreclr/vm/methodtablebuilder.h +++ b/src/coreclr/vm/methodtablebuilder.h @@ -783,9 +783,9 @@ class MethodTableBuilder //----------------------------------------------------------------------------------------- // Returns the substitution to be used in interpreting the signature. - const Substitution & + const Substitution * GetSubstitution() const - { return *m_pSubst; } + { return m_pSubst; } //----------------------------------------------------------------------------------------- // Returns true if the names are equal; otherwise returns false. This is a From b8ea81e7d17185cfd3cff2f9ead52dc8dfa944bc Mon Sep 17 00:00:00 2001 From: Aaron R Robinson Date: Sat, 30 Jul 2022 15:46:09 -0700 Subject: [PATCH 2/2] Missed instance under debug build --- src/coreclr/vm/methodtablebuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 9b33eaef6fc64b..7f623c659c7bb8 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -6622,7 +6622,7 @@ VOID MethodTableBuilder::PlaceInterfaceDeclarationOnClass( DispatchMapTypeID * rgDispatchMapTypeIDs = (DispatchMapTypeID *)_alloca(sizeof(DispatchMapTypeID) * cInterfaceDuplicates); ComputeDispatchMapTypeIDs( pDeclMT, - &pDecl->GetMethodSignature().GetSubstitution(), + pDecl->GetMethodSignature().GetSubstitution(), rgDispatchMapTypeIDs, cInterfaceDuplicates, &cInterfaceDuplicates);