]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add test for raw content starting with dict header
authorStella Lau <laus@fb.com>
Wed, 30 Aug 2017 01:36:18 +0000 (18:36 -0700)
committerStella Lau <laus@fb.com>
Wed, 30 Aug 2017 01:36:18 +0000 (18:36 -0700)
lib/compress/zstd_compress.c
tests/fuzzer.c

index 436e73cee1dc3b4a3504fbf4439474a9f400d745..7249f6fca00cf405f3738cec1e757f249afb7dc1 100644 (file)
@@ -4174,7 +4174,6 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
     /* compression stage */
 #ifdef ZSTD_MULTITHREAD
     if (cctx->appliedParams.nbThreads > 1) {
-        assert(cctx->mtctx != NULL);
         size_t const flushMin = ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp);
         DEBUGLOG(5, "ZSTDMT_compressStream_generic : %u", (U32)flushMin);
         if ( ZSTD_isError(flushMin)
index 9f661175a7e00a63d5dbed21efc74937bff0db9d..db4b33519f0f9527207bacb9ad8953055ac9905d 100644 (file)
@@ -810,6 +810,26 @@ static int basicUnitTests(U32 seed, double compressibility)
         }
         DISPLAYLEVEL(4, "OK \n");
 
+        DISPLAYLEVEL(4, "test%3i : Loading rawContent starting with dict header w/ ZSTD_dm_auto should fail", testNb++);
+        {
+            size_t ret;
+            MEM_writeLE32(dictBuffer+2, ZSTD_MAGIC_DICTIONARY);
+            ret = ZSTD_CCtx_loadDictionary_advanced(
+                    cctx, (const char*)dictBuffer+2, dictSize-2, ZSTD_dlm_byRef, ZSTD_dm_auto);
+            if (!ZSTD_isError(ret)) goto _output_error;
+        }
+        DISPLAYLEVEL(4, "OK \n");
+
+        DISPLAYLEVEL(4, "test%3i : Loading rawContent starting with dict header w/ ZSTD_dm_rawContent should pass", testNb++);
+        {
+            size_t ret;
+            MEM_writeLE32(dictBuffer+2, ZSTD_MAGIC_DICTIONARY);
+            ret = ZSTD_CCtx_loadDictionary_advanced(
+                    cctx, (const char*)dictBuffer+2, dictSize-2, ZSTD_dlm_byRef, ZSTD_dm_rawContent);
+            if (ZSTD_isError(ret)) goto _output_error;
+        }
+        DISPLAYLEVEL(4, "OK \n");
+
         ZSTD_freeCCtx(cctx);
         free(dictBuffer);
         free(samplesSizes);