From 786eb7d42e97478b3ab82d8e7384fd52a870104f Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 17 Nov 2015 12:23:53 +0100 Subject: [PATCH] fixed repcode bug --- lib/zstd_compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.47.3