ensure `pattern` is a 1-byte repetition
authorYann Collet <cyan@fb.com>
Tue, 7 Nov 2017 19:29:28 +0000 (11:29 -0800)
committerYann Collet <cyan@fb.com>
Tue, 7 Nov 2017 19:29:28 +0000 (11:29 -0800)
lib/lz4hc.c

index 5882109..93017f1 100644 (file)
@@ -268,7 +268,8 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch (
             if (nextOffset==1) {
                 /* may be a repeated pattern */
                 if (repeat == rep_untested) {
-                    if ((pattern & 0xFFFF) == (pattern >> 16)) {   /* is it enough ? */
+                    if ( ((pattern & 0xFFFF) == (pattern >> 16))
+                      &  ((pattern & 0xFF)   == (pattern >> 24)) ) {
                         repeat = rep_confirmed;
                         srcPatternLength = LZ4HC_countPattern(ip+4, iHighLimit, pattern) + 4;
                     } else {