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

Zlib memory leak and leastsize assertion #1116

Merged
merged 1 commit into from
Nov 10, 2015
Merged

Zlib memory leak and leastsize assertion #1116

merged 1 commit into from
Nov 10, 2015

Conversation

etcimon
Copy link
Contributor

@etcimon etcimon commented May 21, 2015

This fixes an issue where zlib is not guaranteed to call deflateEnd or inflateEnd.

It also fixes an assertion failure that occurs when the underlying stream is closed prematurely.

… assertion. Secondly, the memory must be guaranteed to be freed even when the stream cannot be finalized
@etcimon
Copy link
Contributor Author

etcimon commented Sep 13, 2015

Bump

@s-ludwig
Copy link
Member

Sorry for having forgot about this. I meant to comment on this for a while.

@s-ludwig
Copy link
Member

I still need to understand the issue with that assertion. This should really have a unit test, but I think that it would be a little safer to, instead of removing the assertion, to set the m_finished flag when a premature end of input is detected.

@etcimon
Copy link
Contributor Author

etcimon commented Nov 10, 2015

The issue is when the connection closes (for an unlimited amount of non-program-related reasons), readChunk -> m_in.leastSize returns 0 and zlib stream sees a premature end of input, and fails on this assertion, so it stands out from other streams where you can end up with a closed connection and fail an enforcement at a higher level to e.g. try again, rather than having the task end unexpectedly as a whole.

@s-ludwig
Copy link
Member

I've fixed this locally by adding a check for empty input in readChunk. I'll pull and then commit my changes on top.

s-ludwig added a commit that referenced this pull request Nov 10, 2015
Zlib memory leak and leastsize assertion
@s-ludwig s-ludwig merged commit 731bd01 into vibe-d:master Nov 10, 2015
s-ludwig added a commit that referenced this pull request Nov 10, 2015
Also adds simple unit tests for GzipInputStream, including a partial input test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants