cecil icon indicating copy to clipboard operation
cecil copied to clipboard

ComputeHeader from CodeWriter.cs has a bug

Open vmpsoft opened this issue 6 years ago • 0 comments

It seems your has a bug here:

for (int i = 0; i < count; i++) { var instruction = items [i]; instruction.offset = offset; offset += instruction.GetSize (); ComputeStackSize (instruction, ref stack_sizes, ref stack_size, ref max_stack); }

for this CIL code:

br l_1 l_2: ... // some code here l_1: ldc.i4 XXXX ... ldc.i4 YYYY brfalse l_2 pop // pop XXXX ...

Your algo will calculate not correct stack_size for commands starting from l_2, because you don't walk to the control flow graph

vmpsoft avatar Apr 05 '19 13:04 vmpsoft