aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csharp/src/ProtocolBuffers/CodedInputStream.cs4
1 files changed, 2 insertions, 2 deletions
diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs
index cb47f1c2..17fcc64b 100644
--- a/csharp/src/ProtocolBuffers/CodedInputStream.cs
+++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs
@@ -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();