diff --git a/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs b/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs index 428ecd8d3..a726c0e8f 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs @@ -179,8 +179,8 @@ namespace ICSharpCode.Decompiler.IL internal override void CheckInvariant(ILPhase phase) { base.CheckInvariant(phase); - Debug.Assert(EntryPoint == Blocks[0]); - Debug.Assert(!IsConnected || EntryPoint.IncomingEdgeCount >= 1); + Debug.Assert(Blocks.Count > 0 && EntryPoint == Blocks[0]); + Debug.Assert(!IsConnected || EntryPoint?.IncomingEdgeCount >= 1); Debug.Assert(Blocks.All(b => b.HasFlag(InstructionFlags.EndPointUnreachable))); Debug.Assert(Blocks.All(b => b.Kind == BlockKind.ControlFlow)); // this also implies that the blocks don't use FinalInstruction Block bodyStartBlock;