Double Dispose() of ZipWritingStream #235

Open
opened 2026-01-29 22:08:49 +00:00 by claunia · 0 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:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#235