fix: update customDictContentEnd after ZDICT_finalizeDictionary in COVER_selectDict - #4769
Open
VirajMishra1 wants to merge 1 commit into
Open
fix: update customDictContentEnd after ZDICT_finalizeDictionary in COVER_selectDict#4769VirajMishra1 wants to merge 1 commit into
VirajMishra1 wants to merge 1 commit into
Conversation
…VER_selectDict customDictContentEnd was computed from dictContentSize before the call to ZDICT_finalizeDictionary(), which overwrites dictContentSize with the actual finalized size (including the dictionary header). The stale pointer was then used in the shrinkDict loop to compute candidate content slices, referencing bytes past the true end of the custom content. Fix: recompute customDictContentEnd immediately after the call, once dictContentSize reflects the finalized value. Fixes facebook#4750
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.
Problem
In
COVER_selectDict(lib/dictBuilder/cover.c),customDictContentEndis computed on line 1055 from the inputdictContentSize:Then on line 1069,
ZDICT_finalizeDictionary()overwritesdictContentSizewith the actual finalized dictionary size (input content plus the header). The two values can differ, socustomDictContentEndis now stale.The stale pointer is used later in the
shrinkDictloop:This produces a wrong source pointer for candidate dictionaries when
shrinkDictis enabled.Fix
Recompute
customDictContentEndimmediately afterZDICT_finalizeDictionary()returns, oncedictContentSizereflects the finalized value.Fixes #4750