Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/DotNet/AssemblyDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,21 @@ void InitializeTargetFrameworkAttribute() {
var caRid = list[i];
if (!readerModule.TablesStream.TryReadCustomAttributeRow(caRid, out var caRow))
continue;

// Prevent a possible infinite loop.
// This can happen when a custom AssemblyResolver calls this function when resolving an AssemblyRef.
// If this function encounters a custom attribute whose type is a MemberRef with a TypeSpec class,
// the MemberRef constructor called by ResolveCustomAttributeType() will call ResolveTypeDef() which
// will make it back to the AssemblyResolver and back to this function creating an infinite loop.
// The TargetFrameworkAttribute will never be generic so we can just skip parsing any generic attributes.
if (!CodedToken.CustomAttributeType.Decode(caRow.Type, out MDToken token))
continue;
if (token.Table == Table.MemberRef &&
(!readerModule.TablesStream.TryReadMemberRefRow(token.Rid, out var mrRow) ||
readerModule.ResolveMemberRefParent(mrRow.Class, gpContext) is TypeSpec ts &&
ts.TypeSig is GenericInstSig))
continue;

var caType = readerModule.ResolveCustomAttributeType(caRow.Type, gpContext);
if (!TryGetName(caType, out var ns, out var name))
continue;
Expand Down
Loading