From 88f72ed942d6ebdca5e551ca292d4dcc0820514b Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Fri, 2 Oct 2020 19:08:10 -0400 Subject: [PATCH] Correct incorrect offcode calculation --- lib/compress/zstd_opt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index dcd9e1929..69e73cb47 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -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; -- 2.47.2