fixed LZ4HC_reverseCountPattern()
authorYann Collet <cyan@fb.com>
Wed, 8 Nov 2017 01:58:59 +0000 (17:58 -0800)
committerYann Collet <cyan@fb.com>
Wed, 8 Nov 2017 01:58:59 +0000 (17:58 -0800)
for multi-bytes patterns
(which is not useful for the time being)

lib/lz4hc.c

index 5e2dd2a..02eafaf 100644 (file)
@@ -173,12 +173,11 @@ static unsigned LZ4HC_reverseCountPattern(const BYTE* ip, const BYTE* const iLow
         if (LZ4_read32(ip-4) != pattern) break;
         ip -= 4;
     }
-    while (likely(ip>iLow)) {
-        const BYTE* bytePtr = (const BYTE*)(&pattern) + 3; /* works for any endianess */
-        if (ip[-1] != *bytePtr) break;
-        ip--; bytePtr--;
-    }
-
+    {   const BYTE* bytePtr = (const BYTE*)(&pattern) + 3; /* works for any endianess */
+        while (likely(ip>iLow)) {
+            if (ip[-1] != *bytePtr) break;
+            ip--; bytePtr--;
+    }   }
     return (unsigned)(iStart - ip);
 }