Fix inflate match output bound check - #204
Open
HDauven wants to merge 1 commit into
Open
Conversation
HDauven
force-pushed
the
fix-match-output-bound-check
branch
from
August 22, 2026 02:20
4929027 to
9abcc07
Compare
HDauven
marked this pull request as ready for review
August 22, 2026 02:37
Collaborator
|
This is probably the correct direction but will have to look over the full issue to see whether there is something else missing here. Also something to look at performance-wise is how changing those checks affects the ability for the compiler do optimize out bounds checks later in that "switch case". Since we don't use unsafe, helping the compiler evade bounds checks and thus reducing branches and emitting code for panics in hot paths is important. |
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.
Fixes #200.
Since
decompress_with_limitwas added, this check has compared an absolute end position with the remaining output capacity. This can send matches throughWriteLenBytesToEndeven when the whole match fits.Compare the match length directly with the remaining capacity. The separate overlap check can also go because
apply_matchalready handles the same case throughtransfer.The overall performance difference is small since this sits outside the main inflate loop, but the check is now correct and avoids unnecessary state-machine work.