File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -901,6 +901,21 @@ void InitializeTargetFrameworkAttribute() {
901
901
var caRid = list [ i ] ;
902
902
if ( ! readerModule . TablesStream . TryReadCustomAttributeRow ( caRid , out var caRow ) )
903
903
continue ;
904
+
905
+ // Prevent a possible infinite loop.
906
+ // This can happen when a custom AssemblyResolver calls this function when resolving an AssemblyRef.
907
+ // If this function encounters a custom attribute whose type is a MemberRef with a TypeSpec class,
908
+ // the MemberRef constructor called by ResolveCustomAttributeType() will call ResolveTypeDef() which
909
+ // will make it back to the AssemblyResolver and back to this function creating an infinite loop.
910
+ // The TargetFrameworkAttribute will never be generic so we can just skip parsing any generic attributes.
911
+ if ( ! CodedToken . CustomAttributeType . Decode ( caRow . Type , out MDToken token ) )
912
+ continue ;
913
+ if ( token . Table == Table . MemberRef &&
914
+ ( ! readerModule . TablesStream . TryReadMemberRefRow ( token . Rid , out var mrRow ) ||
915
+ readerModule . ResolveMemberRefParent ( mrRow . Class , gpContext ) is TypeSpec ts &&
916
+ ts . TypeSig is GenericInstSig ) )
917
+ continue ;
918
+
904
919
var caType = readerModule . ResolveCustomAttributeType ( caRow . Type , gpContext ) ;
905
920
if ( ! TryGetName ( caType , out var ns , out var name ) )
906
921
continue ;
You can’t perform that action at this time.
0 commit comments