Browse Source

#2533: Fix bug in CreatePinnedRegion that could cause pinned regions to be created with the wrong entry point if the original IL had blocks in an unusual order

pull/2549/head
Daniel Grunwald 4 years ago
parent
commit
583771e012
  1. 12
      ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs

12
ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs

@ -581,8 +581,16 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -581,8 +581,16 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
br.TargetBlock.Instructions.RemoveAt(0);
}
}
body.Blocks.Add(innerBlock); // move block into body
// move block into body
if (sourceContainer.Blocks[i] == entryBlock)
{
// ensure entry point comes first
body.Blocks.Insert(0, innerBlock);
}
else
{
body.Blocks.Add(innerBlock);
}
if (!cloneBlocks)
{
sourceContainer.Blocks[i] = new Block(); // replace with dummy block

Loading…
Cancel
Save