diff --git a/blocks/Block.cs b/blocks/Block.cs index 1f10cf1e..1142e016 100644 --- a/blocks/Block.cs +++ b/blocks/Block.cs @@ -252,8 +252,8 @@ namespace de4dot.blocks { removeLastBr(); // Get rid of last br/br.s if present var newInstructions = new List(instructions.Count + other.instructions.Count); - addInstructions(newInstructions, instructions); - addInstructions(newInstructions, other.instructions); + addInstructions(newInstructions, instructions, false); + addInstructions(newInstructions, other.instructions, true); instructions = newInstructions; disconnectFromFallThroughAndTargets(); @@ -265,11 +265,11 @@ namespace de4dot.blocks { updateSources(); } - void addInstructions(IList dest, IList instrs) { + void addInstructions(IList dest, IList instrs, bool clone) { for (int i = 0; i < instrs.Count; i++) { var instr = instrs[i]; if (instr.OpCode != OpCodes.Nop) - dest.Add(instr); + dest.Add(clone ? new Instr(DotNetUtils.clone(instr.Instruction)) : instr); } }