]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[dictBuilder] Fix deadlock in *COVER error case
authorNick Terrell <terrelln@fb.com>
Tue, 27 Aug 2019 01:19:29 +0000 (18:19 -0700)
committerNick Terrell <terrelln@fb.com>
Tue, 27 Aug 2019 01:19:29 +0000 (18:19 -0700)
The COVER and FASTCOVER dictionary builders can deadlock when
dictionary construction errors, likely because there are too few
samples, or too few distinct dmers. The deadlock only occurs when
there are errors.

Fixes #1746.

lib/dictBuilder/cover.c

index 621996759b6aeb67ecc3d101a6ffa5fb13e28caf..4721205da2afccc85b9944f24a3b20a8195b878c 100644 (file)
@@ -919,13 +919,12 @@ void COVER_best_finish(COVER_best_t *best, ZDICT_cover_params_t parameters,
         }
       }
       /* Save the dictionary, parameters, and size */
-      if (!dict) {
-        return;
+      if (dict) {
+        memcpy(best->dict, dict, dictSize);
+        best->dictSize = dictSize;
+        best->parameters = parameters;
+        best->compressedSize = compressedSize;
       }
-      memcpy(best->dict, dict, dictSize);
-      best->dictSize = dictSize;
-      best->parameters = parameters;
-      best->compressedSize = compressedSize;
     }
     if (liveJobs == 0) {
       ZSTD_pthread_cond_broadcast(&best->cond);