Double Dispose() of ZipWritingStream #237

Closed
opened 2026-01-29 22:08:51 +00:00 by claunia · 3 comments
Owner

Originally created by @aienabled on GitHub (Sep 8, 2017).

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!

Originally created by @aienabled on GitHub (Sep 8, 2017). 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: ```C# 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!
claunia added the bugup for grabs labels 2026-01-29 22:08:51 +00:00
Author
Owner

@adamhathcock commented on GitHub (Sep 8, 2017):

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

@adamhathcock commented on GitHub (Sep 8, 2017): Good find. Any chance for a pull request? :)
Author
Owner

@aienabled commented on GitHub (Sep 8, 2017):

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

@aienabled commented on GitHub (Sep 8, 2017): Sure https://github.com/adamhathcock/sharpcompress/pull/295
Author
Owner

@adamhathcock commented on GitHub (Sep 8, 2017):

Thanks!

@adamhathcock commented on GitHub (Sep 8, 2017): Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#237