adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.27k stars 481 forks source link

Double Dispose() of ZipWritingStream #294

Closed aienabled closed 7 years ago

aienabled commented 7 years ago

Hello!

I've noticed that ZipWritingStream on Dispose method call will produce a new ZipEntry. But it doesn't have protection against subsequent Dispose call. For example:

using (var stream = zipWriter.WriteToStream(FileNameHeader, new ZipWriterEntryOptions()))
using (var streamWriter = new StreamWriter(stream))
{
   ...
}

it will call dispose for ZipWritingStream two times and produce two zip entries in the archive. I didn't checked it for other streams (non-zip) but they also could be affected by this issue.

Regards!

adamhathcock commented 7 years ago

Good find. Any chance for a pull request? :)

aienabled commented 7 years ago

Sure https://github.com/adamhathcock/sharpcompress/pull/295

adamhathcock commented 7 years ago

Thanks!