1
0
mirror of https://github.com/facebook/zstd.git synced 2025-04-19 00:44:19 +03:00

add an assert

to help static analyzers understand there is no overflow risk there.
This commit is contained in:
Yann Collet 2025-03-22 18:23:31 -07:00
parent 6775af5b2e
commit 2fec3989c1

View File

@ -425,6 +425,7 @@ static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 targetNbBits
* gain back half the rank.
*/
U32 nBitsToDecrease = ZSTD_highbit32((U32)totalCost) + 1;
assert(nBitsToDecrease <= HUF_TABLELOG_MAX+1);
for ( ; nBitsToDecrease > 1; nBitsToDecrease--) {
U32 const highPos = rankLast[nBitsToDecrease];
U32 const lowPos = rankLast[nBitsToDecrease-1];