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
This commit is contained in:
Yann Collet 2017-09-28 02:23:44 -07:00
parent d6770f80af
commit 377abcc02c

View 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);