From 805dd79551fd657cea287fdbb2ab2905d58af195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Fri, 9 Aug 2019 10:31:06 +0200 Subject: [PATCH] Merge PR #372: Remove invalid exception and handle 0 reads --- src/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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; }