Skip to content

Commit a231572

Browse files
committed
CIL: Fix extraction of opcodes.
1 parent a64c05a commit a231572

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

binary/extractor/cil/Semmle.Extraction.CSharp.IL/ILExtractor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ private void ExtractMethodBody(MethodDefinition method, int methodId) {
9696
var instrId = trap.GetId();
9797

9898
// Basic instruction info
99+
// This is super dumb: The instruction.OpCode returns a short instead of a ushort. So without the
100+
// cast the value for a clt instruction (which has Value 0xFE01) does not fit in a short (which
101+
// has max value 0x7FFF). So it underflows to a negative number.
99102
trap.WriteTuple("il_instruction", instrId, instruction.Offset,
100-
(int)instruction.OpCode.Code);
103+
(ushort)instruction.OpCode.Value);
101104

102105
trap.WriteTuple("il_instruction_method", instrId,
103106
methodId);

0 commit comments

Comments
 (0)