From: Yann Collet Date: Sun, 23 Mar 2025 01:23:31 +0000 (-0700) Subject: add an assert X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4344%2Fhead;p=thirdparty%2Fzstd.git add an assert to help static analyzers understand there is no overflow risk there. --- diff --git a/lib/compress/huf_compress.c b/lib/compress/huf_compress.c index ea0007232..6f2194e79 100644 --- a/lib/compress/huf_compress.c +++ b/lib/compress/huf_compress.c @@ -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];