From 203311dd0b3164902613c5696d27f80dff629c32 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 28 Nov 2017 10:37:50 +0100 Subject: [PATCH] Do not crash in BlockContainer.CheckInvariant --- ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;