]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Correct incorrect offcode calculation
authorsenhuang42 <senhuang96@fb.com>
Fri, 2 Oct 2020 23:08:10 +0000 (19:08 -0400)
committersenhuang42 <senhuang96@fb.com>
Wed, 7 Oct 2020 17:56:25 +0000 (13:56 -0400)
lib/compress/zstd_opt.c

index dcd9e1929e8308d23dbf2547e9ed85dcbb2fdf4c..69e73cb4796a36c95f5f609f25d2c6c506f78a75 100644 (file)
@@ -866,7 +866,7 @@ static void ZSTD_opt_maybeAddLdm(ZSTD_match_t* matches, U32* nbMatches,
     U32 posDiff = currPosInBlock - matchStartPosInBlock;
     /* Note: ZSTD_match_t actually contains offCode and matchLength (before subtracting MINMATCH) */
     U32 candidateMatchLength = matchEndPosInBlock - matchStartPosInBlock - posDiff;
-    U32 candidateOffCode = matchOffset + posDiff + ZSTD_REP_MOVE;
+    U32 candidateOffCode = matchOffset + ZSTD_REP_MOVE;
 
     /* Ensure that current block position is not outside of the match */
     if (currPosInBlock < matchStartPosInBlock
@@ -1146,6 +1146,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
                                         &ldmEndPosInBlock, &ldmOffset,
                                         (U32)(inr-istart), (U32)(iend-inr));
                 }
+
                 if (!nbMatches) {
                     DEBUGLOG(7, "rPos:%u : no match found", cur);
                     continue;