NetworkReader.ReadArray: use .Remaining

This commit is contained in:
vis2k 2022-09-25 12:44:06 +07:00
parent 451cd26b47
commit c9642dbbb2

View File

@ -261,7 +261,7 @@ public static T[] ReadArray<T>(this NetworkReader reader)
// this assumes that a reader for T reads at least 1 bytes
// we can't know the exact size of T because it could have a user created reader
// NOTE: don't add to length as it could overflow if value is int.max
if (length > reader.Capacity - reader.Position)
if (length > reader.Remaining)
{
throw new EndOfStreamException($"Received array that is too large: {length}");
}