COVER_selectDict() uses stale customDictContentEnd after ZDICT_finalizeDictionary modifies dictContentSize
Author: zhangguoen1995Created Aug 31, 2026Updated Aug 31, 2026
Describe the bug
In lib/dictBuilder/cover.c, COVER_selectDict() computes customDictContentEnd at line 1055 based on the initial dictContentSize,Then at line 1069, ZDICT_finalizeDictionary() is called and its return value overwrites dictContentSize,ZDICT_finalizeDictionary()returns the actual dictionary size after adding the header, which can differ from the inputdictContentSize. However, customDictContentEndis **never updated** to reflect the newdictContentSize`.
To Reproduce The currently public API cannot easily trigger this bug, but the bug does exist in the code logic.
Expected behavior
Update customDictContentEnd after ZDICT_finalizeDictionary() modifies dictContentSize.
Source: facebook/zstd