From 5f4cf4dfc7a35db5530522efe41e6540c565f3ef Mon Sep 17 00:00:00 2001 From: Emmanuel Marty Date: Tue, 19 Nov 2019 19:53:46 +0100 Subject: [PATCH] Fix for LZSA1 as well --- src/shrink_block_v1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shrink_block_v1.c b/src/shrink_block_v1.c index 5154e8f..ea5dc35 100644 --- a/src/shrink_block_v1.c +++ b/src/shrink_block_v1.c @@ -304,12 +304,13 @@ static int lzsa_optimize_command_count_v1(lzsa_compressor *pCompressor, const un if (pMatch->length == 0 && (i + 1) < (nEndOffset - LAST_LITERALS) && pBestMatch[i + 1].length >= MIN_MATCH_SIZE_V1 && + pBestMatch[i + 1].length < MAX_VARLEN && pBestMatch[i + 1].offset && i >= pBestMatch[i + 1].offset && (i + pBestMatch[i + 1].length + 1) <= (nEndOffset - LAST_LITERALS) && !memcmp(pInWindow + i - (pBestMatch[i + 1].offset), pInWindow + i, pBestMatch[i + 1].length + 1)) { - int nCurLenSize = lzsa_get_match_varlen_size_v1(pBestMatch[i + 1].length); - int nReducedLenSize = lzsa_get_match_varlen_size_v1(pBestMatch[i + 1].length + 1); + int nCurLenSize = lzsa_get_match_varlen_size_v1(pBestMatch[i + 1].length - MIN_MATCH_SIZE_V1); + int nReducedLenSize = lzsa_get_match_varlen_size_v1(pBestMatch[i + 1].length + 1 - MIN_MATCH_SIZE_V1); if ((nReducedLenSize - nCurLenSize) <= 8) { /* Merge */