From 8aff8b22b1b0917179579e77e7c83cceda27c109 Mon Sep 17 00:00:00 2001 From: de4dot Date: Sat, 4 Aug 2012 23:46:51 +0200 Subject: [PATCH] Appended instructions must be cloned --- blocks/Block.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); } }