]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed issue with small dictionary
authorYann Collet <yann.collet.73@gmail.com>
Thu, 14 Jul 2016 20:43:12 +0000 (22:43 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Thu, 14 Jul 2016 21:27:31 +0000 (23:27 +0200)
.coverity.yml [new file with mode: 0644]
NEWS
lib/compress/zstd_compress.c

diff --git a/.coverity.yml b/.coverity.yml
new file mode 100644 (file)
index 0000000..907f096
--- /dev/null
@@ -0,0 +1,5 @@
+configurationVersion: 1
+
+filters:
+    # third-party embedded
+    - filePath: lib/dictBuilder/divsufsort.c
diff --git a/NEWS b/NEWS
index c34f3175ab90c9040128d2c82aac0623512f8014..cecc8f4985f321184676fef7c00200c758468f48 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
 v0.7.4
+Added : new examples
+Fixed : segfault when using small dictionaries
 Modified : default compression level for CLI is 3
 
+
 v0.7.3
 New : compression format specification
 New : `--` separator, stating that all following arguments are file names. Suggested by Chip Turner.
index e583833446a6f1703e60ce9e860cefa66b907a83..ae182a973e43ff502d846cdfbb53fca4665b5d1f 100644 (file)
@@ -273,9 +273,10 @@ size_t ZSTD_estimateCCtxSize(ZSTD_compressionParameters cParams)
 /*! ZSTD_resetCCtx_advanced() :
     note : 'params' is expected to be validated */
 static size_t ZSTD_resetCCtx_advanced (ZSTD_CCtx* zc,
-                                       ZSTD_parameters params, U64 frameContentSize, U32 reset)
+                                       ZSTD_parameters params, U64 frameContentSize,
+                                       U32 reset, U32 fullBlockSize)
 {   /* note : params considered validated here */
-    const size_t blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params.cParams.windowLog);
+    const size_t blockSize = fullBlockSize ? ZSTD_BLOCKSIZE_MAX : MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params.cParams.windowLog);
     const U32    divider = (params.cParams.searchLength==3) ? 3 : 4;
     const size_t maxNbSeq = blockSize / divider;
     const size_t tokenSpace = blockSize + 11*maxNbSeq;
@@ -357,7 +358,7 @@ size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx)
     if (srcCCtx->stage!=1) return ERROR(stage_wrong);
 
     memcpy(&dstCCtx->customMem, &srcCCtx->customMem, sizeof(ZSTD_customMem));
-    ZSTD_resetCCtx_advanced(dstCCtx, srcCCtx->params, srcCCtx->frameContentSize, 0);
+    ZSTD_resetCCtx_advanced(dstCCtx, srcCCtx->params, srcCCtx->frameContentSize, 0, 1);
     dstCCtx->params.fParams.contentSizeFlag = 0;   /* content size different from the one set during srcCCtx init */
 
     /* copy tables */
@@ -2694,7 +2695,7 @@ static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* zc,
                              const void* dict, size_t dictSize,
                                    ZSTD_parameters params, U64 pledgedSrcSize)
 {
-    size_t const resetError = ZSTD_resetCCtx_advanced(zc, params, pledgedSrcSize, 1);
+    size_t const resetError = ZSTD_resetCCtx_advanced(zc, params, pledgedSrcSize, 1, 0);
     if (ZSTD_isError(resetError)) return resetError;
 
     return ZSTD_compress_insertDictionary(zc, dict, dictSize);