Browse Source

Fix #3051: "InvalidOperationException: Stack empty" when decompiling reference assembly with empty method bodies

pull/3058/head
Daniel Grunwald 2 years ago
parent
commit
9becae2de7
  1. 2
      ICSharpCode.Decompiler/IL/BlockBuilder.cs
  2. 1
      ICSharpCode.Decompiler/IL/ILReader.cs

2
ICSharpCode.Decompiler/IL/BlockBuilder.cs

@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.IL @@ -136,7 +136,7 @@ namespace ICSharpCode.Decompiler.IL
cancellationToken.ThrowIfCancellationRequested();
int start = block.StartILOffset;
// Leave nested containers if necessary
while (start >= currentContainer.EndILOffset)
while (start >= currentContainer.EndILOffset && containerStack.Count > 0)
{
currentContainer = containerStack.Pop();
}

1
ICSharpCode.Decompiler/IL/ILReader.cs

@ -462,6 +462,7 @@ namespace ICSharpCode.Decompiler.IL @@ -462,6 +462,7 @@ namespace ICSharpCode.Decompiler.IL
blocksByOffset[0].Block.Instructions.Add(
new InvalidBranch("Empty body found. Decompiled assembly might be a reference assembly.")
);
stackVariables = Enumerable.Empty<ILVariable>();
return;
}
ILParser.SetBranchTargets(ref reader, isBranchTarget);

Loading…
Cancel
Save