From: Yann Collet Date: Thu, 28 Sep 2017 09:23:44 +0000 (-0700) Subject: zstdmt : better behavior when freeing a context right after a memory allocation error X-Git-Tag: v1.3.2~3^2~21^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377abcc02c9db9cec4f348a04a1caaa45cfa13a7;p=thirdparty%2Fzstd.git zstdmt : better behavior when freeing a context right after a memory allocation error wait for all jobs to be completed, so that freeing can happen safely --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 202d61b6a..5001f4a00 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -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);