Browse Source

Fix crash in SwitchDetection.

pull/887/head
Daniel Grunwald 8 years ago
parent
commit
f42d1a4b34
  1. 7
      ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs

7
ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs

@ -65,11 +65,12 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -65,11 +65,12 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
Body = section.Value
});
}
if (block.Instructions.Last() is Branch) {
if (block.Instructions.Last() is SwitchInstruction) {
// we'll replace the switch
} else {
Debug.Assert(block.Instructions.SecondToLastOrDefault() is IfInstruction);
// Remove branch/leave after if; it's getting moved into a section.
block.Instructions.RemoveAt(block.Instructions.Count - 1);
} else {
Debug.Assert(block.Instructions.Last() is SwitchInstruction);
}
block.Instructions[block.Instructions.Count - 1] = sw;

Loading…
Cancel
Save