Skip to content

Conversation

@llchan
Copy link
Contributor

@llchan llchan commented Jun 22, 2015

This pull request fixes msgpack::zbuffer::write and msgpack_zbuffer_write to handle empty strings correctly. Essentially the deflate call should be skipped entirely when there is no data to write, because it will return Z_BUFFER_ERROR and make the rest of the code think that something is wrong.

This fixes #291.

llchan added 4 commits June 22, 2015 12:58
When a zlib stream has avail_in == 0, it will deflate with a Z_BUF_ERROR
to indicate that "no progress is possible". A zbuffer write with an
empty string will trigger this condition, and the write call
returns/raises an error/exception.  The fix is simple: change the
do/while to a while loop, so that it only tries to deflate if there is
actually data to deflate.
@llchan
Copy link
Contributor Author

llchan commented Jun 22, 2015

The CI tests revealed that zbuffer.h was also missing some static inline keywords, bugs that have been present for a while but we didnt notice because we didnt have tests for the C interface to zbuffer. I fixed them as part of this pull request out of convenience, but if there's a strong preference to split that into a separate PR let me know.

@redboltz
Copy link
Contributor

Thank you for sending the PR! I appreciate your help.

redboltz added a commit that referenced this pull request Jun 23, 2015
Fix zbuffer empty string writes
@redboltz redboltz merged commit 1a6f826 into msgpack:master Jun 23, 2015
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.

zbuffer cannot pack empty strings

2 participants