From: Yann Collet Date: Sat, 17 Jun 2017 00:01:46 +0000 (-0700) Subject: fixed +/-1 error for pledgedSrcSizePlusOne X-Git-Tag: v1.3.0~1^2~17^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aee916e37c159b2fc4c8e273597d36e0d6307797;p=thirdparty%2Fzstd.git fixed +/-1 error for pledgedSrcSizePlusOne --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 937fd3107..6286c5aa6 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -3219,7 +3219,7 @@ size_t ZSTD_compressEnd (ZSTD_CCtx* cctx, DEBUGLOG(5, "end of frame : controlling src size"); if (cctx->pledgedSrcSizePlusOne != cctx->consumedSrcSize+1) { DEBUGLOG(5, "error : pledgedSrcSize = %u, while realSrcSize = %u", - (U32)cctx->frameContentSize, (U32)cctx->consumedSrcSize); + (U32)cctx->pledgedSrcSizePlusOne-1, (U32)cctx->consumedSrcSize); return ERROR(srcSize_wrong); } } return cSize + endResult; @@ -3789,7 +3789,7 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx, ZSTD_parameters params = cctx->requestedParams; if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM) params.cParams = ZSTD_getCParams(cctx->compressionLevel, - cctx->pledgedSrcSizePlusOne+1, 0 /* dictSize */); + cctx->pledgedSrcSizePlusOne-1, 0 /* dictSize */); #ifdef ZSTD_MULTITHREAD if (cctx->nbThreads > 1) { @@ -3798,7 +3798,7 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx, } else #endif { - CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->pledgedSrcSizePlusOne+1) ); + CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->pledgedSrcSizePlusOne-1) ); } } #ifdef ZSTD_MULTITHREAD