Skip to content

Commit

Permalink
Incorrectly reading the TypeArgumentIndex as a U2 (short) instead of …
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Oct 30, 2023
1 parent 03ec8b0 commit bb52ee9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace IKVM.ByteCode.Parsing
{

internal sealed record TypeAnnotationTypeArgumentTargetRecord(ushort Offset, ushort TypeArgumentIndex) : TypeAnnotationTargetRecord
internal sealed record TypeAnnotationTypeArgumentTargetRecord(ushort Offset, byte TypeArgumentIndex) : TypeAnnotationTargetRecord
{

public static bool TryRead(ref ClassFormatReader reader, out TypeAnnotationTargetRecord targetInfo)
Expand All @@ -10,7 +10,7 @@ public static bool TryRead(ref ClassFormatReader reader, out TypeAnnotationTarge

if (reader.TryReadU2(out ushort offset) == false)
return false;
if (reader.TryReadU2(out ushort typeArgumentIndex) == false)
if (reader.TryReadU1(out byte typeArgumentIndex) == false)
return false;

targetInfo = new TypeAnnotationTypeArgumentTargetRecord(offset, typeArgumentIndex);
Expand All @@ -25,7 +25,7 @@ public override int GetSize()
{
var length = 0;
length += sizeof(ushort);
length += sizeof(ushort);
length += sizeof(byte);
return length;
}

Expand All @@ -38,7 +38,7 @@ public override bool TryWrite(ref ClassFormatWriter writer)
{
if (writer.TryWriteU2(Offset) == false)
return false;
if (writer.TryWriteU2(TypeArgumentIndex) == false)
if (writer.TryWriteU1(TypeArgumentIndex) == false)
return false;

return true;
Expand Down

0 comments on commit bb52ee9

Please sign in to comment.