Browse Source

Fix #3549: Do not crash on encountering nil tokens.

pull/3551/head
Siegfried Pammer 4 months ago
parent
commit
6aa9bd8e5e
  1. 9
      ICSharpCode.Decompiler/IL/ILReader.cs

9
ICSharpCode.Decompiler/IL/ILReader.cs

@ -212,7 +212,14 @@ namespace ICSharpCode.Decompiler.IL @@ -212,7 +212,14 @@ namespace ICSharpCode.Decompiler.IL
// Row-IDs < 1 are always invalid.
throw new BadImageFormatException("Invalid metadata token");
}
return MetadataTokens.EntityHandle(token);
var handle = MetadataTokens.EntityHandle(token);
if (handle.IsNil)
{
// The runtime will crash with a BadImageFormatException when it encounters a row-ID of 0.
// We assume the code following this instruction to be unreachable.
throw new BadImageFormatException("Invalid metadata token");
}
return handle;
}
IType ReadAndDecodeTypeReference()

Loading…
Cancel
Save