Browse Source

Fix bug in ILStructure.FindAllBranches

pull/1198/head
Siegfried Pammer 7 years ago
parent
commit
42854c17c5
  1. 5
      ICSharpCode.Decompiler/Disassembler/ILStructure.cs

5
ICSharpCode.Decompiler/Disassembler/ILStructure.cs

@ -109,7 +109,7 @@ namespace ICSharpCode.Decompiler.Disassembler
int entryPoint = -1; int entryPoint = -1;
// entry point is first instruction in loop if prev inst isn't an unconditional branch // entry point is first instruction in loop if prev inst isn't an unconditional branch
if (!isAfterConditionalBranch[loopStart]) if (loopStart > 0 && !isAfterConditionalBranch[loopStart])
entryPoint = allBranches[i].Target; entryPoint = allBranches[i].Target;
bool multipleEntryPoints = false; bool multipleEntryPoints = false;
@ -209,7 +209,7 @@ namespace ICSharpCode.Decompiler.Disassembler
(List<Branch> Branches, BitSet IsAfterUnconditionalBranch) FindAllBranches(BlobReader body) (List<Branch> Branches, BitSet IsAfterUnconditionalBranch) FindAllBranches(BlobReader body)
{ {
var result = new List<Branch>(); var result = new List<Branch>();
var bitset = new BitSet(body.Length); var bitset = new BitSet(body.Length + 1);
body.Reset(); body.Reset();
int target; int target;
while (body.RemainingBytes > 0) { while (body.RemainingBytes > 0) {
@ -231,6 +231,7 @@ namespace ICSharpCode.Decompiler.Disassembler
break; break;
default: default:
ILParser.SkipOperand(ref body, thisOpCode); ILParser.SkipOperand(ref body, thisOpCode);
bitset[body.Offset] = IsUnconditionalBranch(thisOpCode);
break; break;
} }
} }

Loading…
Cancel
Save