]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
zstdmt : better behavior when freeing a context right after a memory allocation error
authorYann Collet <cyan@fb.com>
Thu, 28 Sep 2017 09:23:44 +0000 (02:23 -0700)
committerYann Collet <cyan@fb.com>
Thu, 28 Sep 2017 09:23:44 +0000 (02:23 -0700)
wait for all jobs to be completed, so that freeing can happen safely

lib/compress/zstdmt_compress.c

index 202d61b6ad754a21b3f17a9dc6c404bec6d6937c..5001f4a00d22be15d59c4905852e771bf8ef4a61 100644 (file)
@@ -1014,8 +1014,10 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
     if (input->size > input->pos) {   /* support NULL input */
         if (mtctx->inBuff.buffer.start == NULL) {
             mtctx->inBuff.buffer = ZSTDMT_getBuffer(mtctx->bufPool);
-            if (mtctx->inBuff.buffer.start == NULL)
+            if (mtctx->inBuff.buffer.start == NULL) {
+                ZSTDMT_waitForAllJobsCompleted(mtctx);
                 return ERROR(memory_allocation);
+            }
             mtctx->inBuff.filled = 0;
         }
         {   size_t const toLoad = MIN(input->size - input->pos, mtctx->inBuffSize - mtctx->inBuff.filled);