From: Yann Collet Date: Tue, 17 Nov 2015 11:23:53 +0000 (+0100) Subject: fixed repcode bug X-Git-Tag: zstd-0.4.0^2~23^2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=786eb7d42e97478b3ab82d8e7384fd52a870104f;p=thirdparty%2Fzstd.git fixed repcode bug --- diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index a128ed8cc..95a6e774a 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -863,7 +863,7 @@ size_t ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx, { size_t litLength = ip-anchor; - size_t maxLength = MIN((size_t)(iend-ip-MINMATCH), (size_t)(dictLimit - matchIndex)); /* works even if matchIndex > dictLimit */ + size_t maxLength = matchIndex < dictLimit ? MIN((size_t)(iend-ip-MINMATCH), (size_t)(dictLimit - matchIndex)) : (size_t)(iend-ip-MINMATCH); const BYTE* const iEndCount = ip + maxLength; size_t matchLength = ZSTD_count(ip+MINMATCH, match+MINMATCH, iEndCount); size_t offsetCode = current-matchIndex;