Skip to content

Commit f593921

Browse files
authoredAug 7, 2020
PR #458: Dispose of entry streams returned by ZipFile.GetInputStream
1 parent 75adef5 commit f593921

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
 

‎src/ICSharpCode.SharpZipLib/Zip/FastZip.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,18 @@ private void ExtractFileEntry(ZipEntry entry, string targetName)
636636
{
637637
buffer_ = new byte[4096];
638638
}
639-
if ((events_ != null) && (events_.Progress != null))
640-
{
641-
StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_,
642-
events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
643-
}
644-
else
639+
640+
using (var inputStream = zipFile_.GetInputStream(entry))
645641
{
646-
StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_);
642+
if ((events_ != null) && (events_.Progress != null))
643+
{
644+
StreamUtils.Copy(inputStream, outputStream, buffer_,
645+
events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
646+
}
647+
else
648+
{
649+
StreamUtils.Copy(inputStream, outputStream, buffer_);
650+
}
647651
}
648652

649653
if (events_ != null)

0 commit comments

Comments
 (0)