From: Nick Terrell Date: Sun, 11 Dec 2016 02:46:55 +0000 (-0800) Subject: Simplify segfault fix X-Git-Tag: v1.1.2~15^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3826207a70779477703fcfe11f652d5cea9cff8c;p=thirdparty%2Fzstd.git Simplify segfault fix Take advantage of the fact that `chainLog <= windowLog`. --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index a575534c3..aef769fc0 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -2277,7 +2277,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* cctx, if (cctx->lowLimit > (1<<30)) { U32 const btplus = (cctx->params.cParams.strategy == ZSTD_btlazy2) | (cctx->params.cParams.strategy == ZSTD_btopt) | (cctx->params.cParams.strategy == ZSTD_btopt2); U32 const chainMask = (1 << (cctx->params.cParams.chainLog - btplus)) - 1; - U32 const supLog = MAX(MAX(cctx->params.cParams.chainLog, 17 /* blockSize */), cctx->params.cParams.windowLog); + U32 const supLog = MAX(cctx->params.cParams.windowLog, 17 /* blockSize */); U32 const newLowLimit = (cctx->lowLimit & chainMask) + (1 << supLog); /* preserve position % chainSize, ensure current-repcode doesn't underflow */ U32 const correction = cctx->lowLimit - newLowLimit; ZSTD_reduceIndex(cctx, correction);