diff --git a/src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs b/src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs index 6ecaafcea..a924a7ffc 100644 --- a/src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs +++ b/src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs @@ -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; }