summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/lz4opt.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h
index 94b38e0..46797ef 100644
--- a/lib/lz4opt.h
+++ b/lib/lz4opt.h
@@ -133,7 +133,10 @@ FORCE_INLINE int LZ4HC_BinTree_InsertAndGetAllMatches (
if (matchLength > best_mlen) {
best_mlen = matchLength;
if (matches) {
- matches[mnum].off = (int)(ip - match);
+ if (matchIndex >= dictLimit)
+ matches[mnum].off = (int)(ip - match);
+ else
+ matches[mnum].off = (int)(ip - (base + matchIndex)); /* virtual matchpos */
matches[mnum].len = (int)matchLength;
mnum++;
}