|
@@ -1429,10 +1429,10 @@ namespace Google.Protobuf
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- byte[] skipBuffer = new byte[1024];
|
|
|
|
|
|
+ byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)];
|
|
while (amountToSkip > 0)
|
|
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)
|
|
if (bytesRead <= 0)
|
|
{
|
|
{
|
|
throw InvalidProtocolBufferException.TruncatedMessage();
|
|
throw InvalidProtocolBufferException.TruncatedMessage();
|