From: Yann Collet Date: Tue, 22 Oct 2024 22:19:06 +0000 (-0700) Subject: ensure `lastBlock` is correctly determined X-Git-Tag: v1.5.7^2~71^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ae34e4c96265f1face970f3458836b3edf2e76d;p=thirdparty%2Fzstd.git ensure `lastBlock` is correctly determined reported by @terrelln --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index e7a07a484..edb71ae50 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -4540,8 +4540,8 @@ static size_t ZSTD_compress_frameChunk(ZSTD_CCtx* cctx, while (remaining) { ZSTD_matchState_t* const ms = &cctx->blockState.matchState; - U32 const lastBlock = lastFrameChunk & (blockSizeMax >= remaining); size_t const blockSize = ZSTD_optimalBlockSize(cctx, ip, remaining, blockSizeMax, cctx->appliedParams.cParams.strategy, savings); + U32 const lastBlock = lastFrameChunk & (blockSize == remaining); assert(blockSize <= remaining); /* TODO: See 3090. We reduced MIN_CBLOCK_SIZE from 3 to 2 so to compensate we are adding