Skip to content

Commit

Permalink
Merge PR #372: Remove invalid exception and handle 0 reads
Browse files Browse the repository at this point in the history
  • Loading branch information
piksel authored Aug 9, 2019
1 parent 36ece7a commit 805dd79
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ public override int Read(byte[] buffer, int offset, int count)
if (inf.IsFinished)
{
ReadFooter();
} else if (inf.RemainingInput == 0) {
// If the stream is not finished but we have no more data to read, don't keep looping forever
throw new GZipException("Unexpected EOF");
}

if (bytesRead > 0)
// Attempting to read 0 bytes will never yield any bytesRead, so we return instead of looping forever
if (bytesRead > 0 || count == 0)
{
return bytesRead;
}
Expand Down

0 comments on commit 805dd79

Please sign in to comment.