Skip to content

Commit 41660e8

Browse files
update
Making the reader use the already calculated readSize.
1 parent 5184e54 commit 41660e8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

com.unity.netcode.gameobjects/Runtime/Serialization/FastBufferReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ public unsafe void ReadValue(out string s, bool oneByteChars = false)
577577
{
578578
throw new OverflowException($"Invalid reader position detected when trying to read a string of size {(uint)readSize}! This can result from reading the same serialized value more than once causing the position to be improperly offset.");
579579
}
580-
s = "".PadRight(length);
580+
s = "".PadRight(readSize);
581581
int target = s.Length;
582582
fixed (char* native = s)
583583
{
@@ -628,7 +628,7 @@ public unsafe void ReadValueSafe(out string s, bool oneByteChars = false)
628628
throw new OverflowException($"Invalid reader position detected when trying to read a string of size {(uint)readSize}! This can result from reading the same serialized value more than once causing the position to be improperly offset.");
629629
}
630630

631-
if (!TryBeginReadInternal(length * (oneByteChars ? 1 : sizeof(char))))
631+
if (!TryBeginReadInternal(readSize))
632632
{
633633
throw new OverflowException("Reading past the end of the buffer");
634634
}

0 commit comments

Comments
 (0)