Skip to content

Commit 4a0ddd1

Browse files
committed
fixup! Use Streams for Filter
1 parent 09dc86e commit 4a0ddd1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

LibGit2Sharp/Core/GitBufWriteStream.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@ internal GitBufWriteStream(IntPtr gitBufPointer)
1919

2020
protected override void Dispose(bool disposing)
2121
{
22-
using (var gitBuf = gitBufPointer.MarshalAs<GitBuf>())
23-
WriteTo(gitBuf);
22+
if (base.CanSeek) // False if stream has already been written/closed
23+
{
24+
using (var gitBuf = gitBufPointer.MarshalAs<GitBuf>())
25+
{
26+
WriteTo(gitBuf);
27+
}
28+
}
2429

2530
base.Dispose(disposing);
2631
}
2732

2833
private void WriteTo(GitBuf gitBuf)
2934
{
30-
if (!base.CanSeek)
31-
{
32-
// Already closed; already written
33-
return;
34-
}
35-
3635
Seek(0, SeekOrigin.Begin);
3736

3837
var length = (int)Length;

0 commit comments

Comments
 (0)