]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
ensure `lastBlock` is correctly determined
authorYann Collet <cyan@fb.com>
Tue, 22 Oct 2024 22:19:06 +0000 (15:19 -0700)
committerYann Collet <cyan@fb.com>
Wed, 23 Oct 2024 18:50:57 +0000 (11:50 -0700)
reported by @terrelln

lib/compress/zstd_compress.c

index e7a07a48415968d3520e964ca041a58d74a65fd6..edb71ae50ddb883d8892e656c0e59c7dfcf8065f 100644 (file)
@@ -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