mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkReader.ReadBytesSegment: use .Remaining
This commit is contained in:
parent
98be66ec13
commit
78fb0b57ae
@ -162,8 +162,8 @@ public byte[] ReadBytes(byte[] bytes, int count)
|
|||||||
/// <summary>Read 'count' bytes allocation-free as ArraySegment that points to the internal array.</summary>
|
/// <summary>Read 'count' bytes allocation-free as ArraySegment that points to the internal array.</summary>
|
||||||
public ArraySegment<byte> ReadBytesSegment(int count)
|
public ArraySegment<byte> ReadBytesSegment(int count)
|
||||||
{
|
{
|
||||||
// check if within buffer limits
|
// ensure remaining
|
||||||
if (Position + count > buffer.Count)
|
if (Remaining < count)
|
||||||
{
|
{
|
||||||
throw new EndOfStreamException($"ReadBytesSegment can't read {count} bytes because it would read past the end of the stream. {ToString()}");
|
throw new EndOfStreamException($"ReadBytesSegment can't read {count} bytes because it would read past the end of the stream. {ToString()}");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user