From: senhuang42 Date: Fri, 2 Oct 2020 23:08:10 +0000 (-0400) Subject: Correct incorrect offcode calculation X-Git-Tag: v1.4.7~57^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88f72ed942d6ebdca5e551ca292d4dcc0820514b;p=thirdparty%2Fzstd.git Correct incorrect offcode calculation --- 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;