Fix calculation for using the "fast path" with Deflate#25
Merged
Conversation
dunhor
commented
Jun 25, 2026
DHowett
reviewed
Jun 25, 2026
DHowett
approved these changes
Jun 26, 2026
DHowett
left a comment
Member
There was a problem hiding this comment.
Only nits - happy to double tap if you fix 'em
| struct inflatelib_state; /* Opaque to client applications */ | ||
|
|
||
| /* | ||
| * This struct stores all data and state for decompressing Defalte/Deflate64 encoded data. With the exception of |
Member
There was a problem hiding this comment.
Suggested change
| * This struct stores all data and state for decompressing Defalte/Deflate64 encoded data. With the exception of | |
| * This struct stores all data and state for decompressing Deflate/Deflate64 encoded data. With the exception of |
nit
| /* | ||
| * | ||
| * "Inflates" the Deflate64 encoded data from next_in/avail_in, writing the decoded data to next_out/avail_out. The | ||
| * 'stream' MUST be in either the "initialized" state or the "Deflate64" state. |
Member
There was a problem hiding this comment.
nit: should this get the same "This function returns..." as above (inflate)?
| int result = 0; | ||
| while (stream.avail_in > 0) | ||
| for (std::size_t i = 0; size > 0; ++i) | ||
| { |
Member
There was a problem hiding this comment.
a comment here about how you put it at the end of the buffer to make sure ASAN can detect reads off the end may not go unmissed
DHowett
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A prior optimization I made changed the bitstream code to only do a single
< 16check for the unchecked reading of data and then always read two bytes. This means that the previous size check for continuing down the fast path was no longer accurate and needs to be updated, in this case both Deflate and Deflate64 need 8 bytes.New tests added that stress these scenarios and I made an attempt to augment the fuzz tests to test these scenarios, however I have yet to hit an actual failure yet, even without this change.