Browse Source

Fix #2073: Ensure the startOffsetVar actually appears in the expected instruction, not somewhere else.

pull/2077/head
Daniel Grunwald 5 years ago
parent
commit
3409ffca25
  1. 4
      ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs

4
ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs

@ -205,6 +205,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!CheckContainerLengthVariableUseCount(containerLengthVar, startIndexKind)) { if (!CheckContainerLengthVariableUseCount(containerLengthVar, startIndexKind)) {
return; return;
} }
if (!call.IsDescendantOf(block.Instructions[pos]))
return;
// startOffsetVar might be used deep inside a complex statement, ensure we can inline up to that point: // startOffsetVar might be used deep inside a complex statement, ensure we can inline up to that point:
for (int i = startPos; i < pos; i++) { for (int i = startPos; i < pos; i++) {
if (!ILInlining.CanInlineInto(block.Instructions[pos], startOffsetVar, block.Instructions[i])) if (!ILInlining.CanInlineInto(block.Instructions[pos], startOffsetVar, block.Instructions[i]))
@ -275,6 +277,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
if (!(sliceLengthVar.LoadInstructions.Single().Parent is CallInstruction call)) if (!(sliceLengthVar.LoadInstructions.Single().Parent is CallInstruction call))
return; return;
if (!call.IsDescendantOf(block.Instructions[pos]))
return;
if (!IsSlicingMethod(call.Method)) if (!IsSlicingMethod(call.Method))
return; return;
if (call.Arguments.Count != 3) if (call.Arguments.Count != 3)

Loading…
Cancel
Save