From 6ef2accebfa67328a0683313e2468316937a2f68 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Sun, 3 May 2020 17:25:17 +0100 Subject: [PATCH] Dispose of entry streams returned by ZipFile.GetInputStream --- src/ICSharpCode.SharpZipLib/Zip/FastZip.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs b/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs index 319645a5b..2420e27c1 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs @@ -621,14 +621,18 @@ private void ExtractFileEntry(ZipEntry entry, string targetName) { buffer_ = new byte[4096]; } - if ((events_ != null) && (events_.Progress != null)) - { - StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_, - events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size); - } - else + + using (var inputStream = zipFile_.GetInputStream(entry)) { - StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_); + if ((events_ != null) && (events_.Progress != null)) + { + StreamUtils.Copy(inputStream, outputStream, buffer_, + events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size); + } + else + { + StreamUtils.Copy(inputStream, outputStream, buffer_); + } } if (events_ != null)