From 7a6343fb1bf73f4108a838f001b6836c9ac11465 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 2 Feb 2016 16:00:50 +0100 Subject: [PATCH] fixed encoding bugs --- lib/zstd_compress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index 7252d750b..3dd865151 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -251,6 +251,7 @@ size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx) dstCCtx->dictBase = srcCCtx->dictBase; dstCCtx->dictLimit = srcCCtx->dictLimit; dstCCtx->lowLimit = srcCCtx->lowLimit; + dstCCtx->loadedDictEnd = srcCCtx->loadedDictEnd; /* copy entropy tables */ dstCCtx->flagStaticTables = srcCCtx->flagStaticTables; @@ -1911,7 +1912,8 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc, if (remaining < blockSize) blockSize = remaining; if ((U32)(ip+blockSize - zc->base) > zc->loadedDictEnd + maxDist) { /* enforce maxDist */ - zc->lowLimit = (U32)(ip+blockSize - zc->base) - maxDist; + U32 newLowLimit = (U32)(ip+blockSize - zc->base) - maxDist; + if (zc->lowLimit < newLowLimit) zc->lowLimit = newLowLimit; if (zc->dictLimit < zc->lowLimit) zc->dictLimit = zc->lowLimit; }