Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flushing GZipOutputStream so all data is written to the underlying stream #225

Merged
merged 3 commits into from
Jun 15, 2019

Conversation

adamreeve
Copy link
Contributor

I found that when flushing a GZipOutputStream no data was not actually written to the underlying stream before it was flushed due to the !deflater_.IsNeedingInput check in DeflaterOutputStream.Deflate.

This PR fixes that and a couple of other related issues I came across when testing:

  • Don't loop forever when reading from an unfinished stream
  • Fix an infinite loop when flushing a deflate output stream with zero compression

I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.

When flushing a GZipOutputStream, ensure we deflate
all data in the input buffer and write it to the
underlying stream before we flush the underlying stream.
DeflaterEngine.DeflateStored would always write more output even if
there was no more input data to write, resulting in an infinite loop.
@piksel piksel added this to the post 1.0 milestone Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants