Fix for instructions with invalid targets
This commit is contained in:
parent
182dc10ffc
commit
15c715e312
|
@ -82,9 +82,9 @@ namespace de4dot.blocks {
|
|||
if (!LastInstr.isBr())
|
||||
return;
|
||||
|
||||
if (fallThrough != null || targets == null || targets.Count != 1)
|
||||
if (fallThrough != null || (LastInstr.Operand != null && (targets == null || targets.Count != 1)))
|
||||
throw new ApplicationException("Invalid block state when last instr is a br/br.s");
|
||||
fallThrough = targets[0];
|
||||
fallThrough = LastInstr.Operand != null ? targets[0] : null;
|
||||
targets = null;
|
||||
instructions.RemoveAt(instructions.Count - 1);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,9 @@ namespace de4dot.blocks {
|
|||
switch (instr.OpCode.OperandType) {
|
||||
case OperandType.ShortInlineBrTarget:
|
||||
case OperandType.InlineBrTarget:
|
||||
targets = new List<int> { instrToIndex[(Instruction)instr.Operand] };
|
||||
var targetInstr = instr.Operand as Instruction;
|
||||
if (targetInstr != null)
|
||||
targets = new List<int> { instrToIndex[targetInstr] };
|
||||
break;
|
||||
|
||||
case OperandType.InlineSwitch:
|
||||
|
@ -138,7 +140,9 @@ namespace de4dot.blocks {
|
|||
switch (lastInstr.OpCode.OperandType) {
|
||||
case OperandType.ShortInlineBrTarget:
|
||||
case OperandType.InlineBrTarget:
|
||||
block.Targets = new List<Block> { instrToBlock[instrToIndex[(Instruction)lastInstr.Operand]] };
|
||||
var targetInstr = lastInstr.Operand as Instruction;
|
||||
if (targetInstr != null)
|
||||
block.Targets = new List<Block> { instrToBlock[instrToIndex[targetInstr]] };
|
||||
break;
|
||||
|
||||
case OperandType.InlineSwitch:
|
||||
|
|
Loading…
Reference in New Issue
Block a user