]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix Rep Code Initialization
authorW. Felix Handte <w@felixhandte.com>
Thu, 3 May 2018 00:30:03 +0000 (20:30 -0400)
committerW. Felix Handte <w@felixhandte.com>
Wed, 23 May 2018 21:53:03 +0000 (17:53 -0400)
lib/compress/zstd_fast.c

index 8f3d33e666088786c89fb046ab2dd1429a3af304..067efba5e374248caca517f59f333505ae73c6ae 100644 (file)
@@ -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;
     }