From 2fec3989c1567e0bd9b52100ad8c821886acf402 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sat, 22 Mar 2025 18:23:31 -0700 Subject: [PATCH] add an assert to help static analyzers understand there is no overflow risk there. --- lib/compress/huf_compress.c | 1 + 1 file changed, 1 insertion(+) 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]; -- 2.47.2