]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed one race scenario hc_patchfrom_part2 4279/head
authorYann Collet <cyan@fb.com>
Sun, 2 Feb 2025 05:23:36 +0000 (21:23 -0800)
committerYann Collet <cyan@fb.com>
Sun, 2 Feb 2025 05:23:36 +0000 (21:23 -0800)
lib/compress/zstdmt_compress.c
tests/zstreamtest.c

index 91f158084f78cd833f8091340c3e16e21da012e3..68f9111490ce93504c2af209eb39e54676cf2d08 100644 (file)
@@ -837,6 +837,7 @@ _endJob:
     job->cSize += lastCBlockSize;
     job->consumed = job->src.size;  /* when job->consumed == job->src.size , compression job is presumed completed */
     if (job->flush_mutex != NULL) {
+        assert(job->flush_cond != NULL);
         ZSTD_pthread_mutex_unlock(&job->job_mutex);
         ZSTD_PTHREAD_MUTEX_LOCK(job->flush_mutex);
         ZSTD_pthread_cond_signal(job->flush_cond);   /* warns some more data is ready to be flushed */
@@ -1603,8 +1604,6 @@ static size_t ZSTDMT_flushProduced(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, u
                 DEBUGLOG(5, "dstBuffer released");
                 mtctx->jobs[wJobID].dstBuff = g_nullBuffer;
                 mtctx->jobs[wJobID].cSize = 0;   /* ensure this job slot is considered "not started" in future check */
-                mtctx->jobs[wJobID].flush_mutex = NULL;
-                mtctx->jobs[wJobID].flush_cond = NULL;
                 mtctx->consumed += srcSize;
                 mtctx->produced += cSize;
                 mtctx->doneJobID++;
index b8290fefcbc8d0a9359aec145d21365d8ff0feeb..e87a52328134cbf4b3453d8e24590026f48b13ff 100644 (file)
@@ -2900,7 +2900,7 @@ static int fuzzerTests_newAPI(U32 seed, int nbTests, int startTest,
         U32 lseed;
         int opaqueAPI;
         const BYTE* srcBuffer;
-        size_t totalTestSize, totalGenSize, cSize;
+        size_t totalTestSize, totalGenSize, cSize=0;
         XXH64_state_t xxhState;
         U64 crcOrig;
         U32 resetAllowed = 1;