diff --git a/LibGit2Sharp/Core/WriteStream.cs b/LibGit2Sharp/Core/WriteStream.cs index 37db8af8c..845fecd1d 100644 --- a/LibGit2Sharp/Core/WriteStream.cs +++ b/LibGit2Sharp/Core/WriteStream.cs @@ -49,16 +49,16 @@ public override long Seek(long offset, SeekOrigin origin) public override void Write(byte[] buffer, int offset, int count) { + int res; unsafe { fixed (byte* bufferPtr = &buffer[offset]) { - if (nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count) < 0) - { - throw new LibGit2SharpException("failed to write to next buffer"); - } + res = nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count); } } + + Ensure.Int32Result(res); } } }