]> granicus.if.org Git - xz/commitdiff
liblzma: Fix a compression-ratio regression in LZMA1/2 in fast mode.
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 21 Feb 2015 21:40:26 +0000 (23:40 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sat, 21 Feb 2015 21:40:26 +0000 (23:40 +0200)
The bug was added in the commit
f48fce093b07aeda95c18850f5e086d9f2383380 and thus
affected 5.1.4beta and 5.2.0. Luckily the bug cannot
cause data corruption or other nasty things.

src/liblzma/lzma/lzma_encoder_optimum_fast.c

index 8922cbd91d3fce6d74d3ad0a8e13a3914421e9e4..9b30347cbc4279d4e66828c5bff605483de12fc7 100644 (file)
@@ -152,7 +152,7 @@ lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf,
        // the old buf pointer instead of recalculating it with mf_ptr().
        ++buf;
 
-       const uint32_t limit = len_main - 1;
+       const uint32_t limit = my_max(2, len_main - 1);
 
        for (uint32_t i = 0; i < REPS; ++i) {
                if (memcmp(buf, buf - coder->reps[i] - 1, limit) == 0) {