Skip to content

Commit 805dd79

Browse files
authored
Merge PR #372: Remove invalid exception and handle 0 reads
1 parent 36ece7a commit 805dd79

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,10 @@ public override int Read(byte[] buffer, int offset, int count)
139139
if (inf.IsFinished)
140140
{
141141
ReadFooter();
142-
} else if (inf.RemainingInput == 0) {
143-
// If the stream is not finished but we have no more data to read, don't keep looping forever
144-
throw new GZipException("Unexpected EOF");
145142
}
146143

147-
if (bytesRead > 0)
144+
// Attempting to read 0 bytes will never yield any bytesRead, so we return instead of looping forever
145+
if (bytesRead > 0 || count == 0)
148146
{
149147
return bytesRead;
150148
}

0 commit comments

Comments
 (0)