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.
The issue was occurring when attempting to flush lz77 (so
data
was empty), such that the first window was filling the buffer.Includes a failing test case which passes after the fix. Also includes a deduplicating cleanup of
lz77_compress_block
-- not knowing anything about lz77, I couldn't diagnose the issue until this refactoring. The refactoring makes it explicit where the first window behavior differs from the normal case, which made it clearer to understand and calls out necessary special behavior (likeoverlap
not getting added tocurrent_block_input_bytes
to prevent off-by-one-errors in this particular case, which is different from all the others).I also confirmed that this fixes my bug in image-rs/image-png#147. I haven't checked @newpavlov's, but since it fixes the reduced case from that created by @lkolbly, it should.