From: W. Felix Handte Date: Thu, 3 May 2018 00:30:03 +0000 (-0400) Subject: Fix Rep Code Initialization X-Git-Tag: v1.3.5~3^2~44^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c31ee3c7f827ebb1f3141ca4162e4721d3617752;p=thirdparty%2Fzstd.git Fix Rep Code Initialization --- diff --git a/lib/compress/zstd_fast.c b/lib/compress/zstd_fast.c index 8f3d33e66..067efba5e 100644 --- a/lib/compress/zstd_fast.c +++ b/lib/compress/zstd_fast.c @@ -91,8 +91,10 @@ size_t ZSTD_compressBlock_fast_generic( assert(hasDict == ZSTD_noDict || hasDict == ZSTD_dictMatchState); /* init */ - ip += (ip==lowest); - { U32 const maxRep = (U32)(ip-lowest); + ip += (hasDict == ZSTD_noDict && ip == lowest); + { U32 const maxRep = hasDict == ZSTD_dictMatchState ? + (U32)(ip - dictLowest) : + (U32)(ip - lowest); if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0; if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0; }