From: Yann Collet Date: Sat, 20 Jan 2018 02:19:09 +0000 (-0800) Subject: zstdmt : fixed last job size X-Git-Tag: v1.3.4~1^2~67^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7ef3a219c1981617adfcd9c04086e67b41a123b;p=thirdparty%2Fzstd.git zstdmt : fixed last job size --- diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 3e665f574..c204fb84b 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -1220,7 +1220,8 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx, if ( (mtctx->jobReady) || (mtctx->inBuff.filled >= newJobThreshold) /* filled enough : let's compress */ || ( (endOp != ZSTD_e_continue) && (mtctx->inBuff.filled > 0) ) ) { /* avoid overwriting job round buffer */ - CHECK_F( ZSTDMT_createCompressionJob(mtctx, mtctx->targetSectionSize, 0 /* endFrame */) ); + size_t const jobSize = MIN(mtctx->inBuff.filled - mtctx->prefixSize, mtctx->targetSectionSize); + CHECK_F( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp==ZSTD_e_end) ); } /* check for potential compressed data ready to be flushed */