Commit ca2adbd5 authored by Jon Skeet's avatar Jon Skeet

Fix incorrect handling of non-seekable streams.

This mirrors commit 7c86bbbc7a3365c034d82173b38ec4427b98b3b2 in the pull request to
the main protobuf project, but also reduces the size of the buffer created. (There's no point in
creating a 1024-byte buffer if we're only skipping 5 bytes...)
parent eb70bd0b
......@@ -1429,10 +1429,10 @@ namespace Google.Protobuf
}
else
{
byte[] skipBuffer = new byte[1024];
byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)];
while (amountToSkip > 0)
{
int bytesRead = input.Read(skipBuffer, 0, skipBuffer.Length);
int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip));
if (bytesRead <= 0)
{
throw InvalidProtocolBufferException.TruncatedMessage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment