Browse Source

Do not match lock if lockObj is used in or after the try block.

pull/863/head
Siegfried Pammer 8 years ago
parent
commit
8285d01cad
  1. 6
      ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs

6
ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs

@ -60,6 +60,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -60,6 +60,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (!(body.FinallyBlock is BlockContainer finallyContainer) || !MatchExitBlock(finallyContainer.EntryPoint, null, objectStore.Variable))
return false;
if (objectStore.Variable.LoadCount > 1)
return false;
context.Step("LockTransformV2", block);
block.Instructions.RemoveAt(i - 1);
block.Instructions.RemoveAt(i - 2);
@ -102,6 +104,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -102,6 +104,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (!(body.FinallyBlock is BlockContainer finallyContainer) || !MatchExitBlock(finallyContainer.EntryPoint, flagStore.Variable, objectStore.Variable))
return false;
if (objectStore.Variable.LoadCount > 1)
return false;
context.Step("LockTransformV4", block);
block.Instructions.RemoveAt(i - 1);
tryContainer.EntryPoint.Instructions.RemoveAt(0);
@ -145,6 +149,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -145,6 +149,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (!(body.FinallyBlock is BlockContainer finallyContainer) || !MatchExitBlock(finallyContainer.EntryPoint, flagStore.Variable, objectStore.Variable))
return false;
if (objectStore.Variable.LoadCount > 2)
return false;
context.Step("LockTransformRoslyn", block);
block.Instructions.RemoveAt(i - 1);
block.Instructions.RemoveAt(i - 2);

Loading…
Cancel
Save