]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
conservatively estimate over-splitting in presence of incompressible loss
authorYann Collet <cyan@fb.com>
Tue, 22 Oct 2024 22:25:45 +0000 (15:25 -0700)
committerYann Collet <cyan@fb.com>
Wed, 23 Oct 2024 18:50:57 +0000 (11:50 -0700)
ensure data can never be expanded by more than 3 bytes per full block.

lib/compress/zstd_compress.c

index edb71ae50ddb883d8892e656c0e59c7dfcf8065f..85966d8880ebafd9c23e127f92604719507ac6f5 100644 (file)
@@ -4587,6 +4587,7 @@ static size_t ZSTD_compress_frameChunk(ZSTD_CCtx* cctx,
             }  /* if (ZSTD_useTargetCBlockSize(&cctx->appliedParams))*/
 
             if (cSize < blockSize) savings += (blockSize - cSize);
+            else if (savings) savings--;
             ip += blockSize;
             assert(remaining >= blockSize);
             remaining -= blockSize;