]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Properly Initialize Repcode Values
authorW. Felix Handte <w@felixhandte.com>
Wed, 9 May 2018 19:23:22 +0000 (15:23 -0400)
committerW. Felix Handte <w@felixhandte.com>
Fri, 25 May 2018 17:13:28 +0000 (13:13 -0400)
lib/compress/zstd_double_fast.c

index 8c11d8ebef5cb137729ae077048919a270552c07..2bcd4b5d0608707c23e59a5aed6a8a2fce51c573 100644 (file)
@@ -89,11 +89,13 @@ size_t ZSTD_compressBlock_doubleFast_generic(
                                      lowestDictIndex + dictIndexDelta :
                                      localLowestIndex;
 
-    (void)dictMode;
+    assert(dictMode == ZSTD_noDict || dictMode == ZSTD_dictMatchState);
 
     /* init */
-    ip += (ip==localLowest);
-    {   U32 const maxRep = (U32)(ip-localLowest);
+    ip += (dictMode == ZSTD_noDict && ip == localLowest);
+    {   U32 const maxRep = dictMode == ZSTD_dictMatchState ?
+                           (U32)(ip - dictLowest) :
+                           (U32)(ip - localLowest);
         if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0;
         if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0;
     }