Skip to content

Commit

Permalink
Minimum fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Oct 14, 2020
1 parent 8cf9b8c commit 0f23047
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Mono.Cecil.Cil/MethodBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,23 @@ InstructionOffset ResolveInstructionOffset(InstructionOffset inputOffset, ref In
for (int i = cache.Index; i < items.Length; i++) {
cache.Index = i;
cache.Offset = size;
cache.Instruction = items [i];

var item = items [i];

// Allow for trailing null values in the case of
// instructions.Size < instructions.Capacity
if (item == null)
break;

cache.Instruction = item;

if (cache.Offset == offset)
return new InstructionOffset (cache.Instruction);

if (cache.Offset > offset)
return new InstructionOffset (items [i - 1]);

size += items [i].GetSize ();
size += item.GetSize ();
}

return new InstructionOffset ();
Expand Down

0 comments on commit 0f23047

Please sign in to comment.