Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions TerrariaServerAPI/TerrariaApi.Server/StreamExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,16 @@ public static byte[] ReadBytes(this Stream s, int count)
throw new ArgumentOutOfRangeException("count");
}
byte[] array = new byte[count];
int num = 0;
do
int offset = 0;
while (count > 0)
{
int num2 = s.Read(array, num, count);
if (num2 == 0)
int numBytesRead = s.Read(array, offset, count);
if (numBytesRead == 0)
{
break;
throw new EndOfStreamException("End of stream");
}
num += num2;
count -= num2;
}
while (count > 0);
if (num != array.Length)
{
byte[] array2 = new byte[num];
Buffer.BlockCopy(array, 0, array2, 0, num);
array = array2;
offset += numBytesRead;
count -= numBytesRead;
}
return array;
}
Expand Down
Loading