diff --git a/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs b/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs index 16da8b455..aba4ffaea 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs @@ -636,14 +636,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)