]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move scan_start check, based on Cloudflare commit
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Sun, 11 Aug 2019 16:55:14 +0000 (18:55 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 22 Oct 2019 07:17:22 +0000 (09:17 +0200)
5f1bd2b72e5966aa8a4f942e6e8050a050161cf9

match_p.h

index 776d6cec3500d08b076b2fb36de32075259bf6e8..363c7a3ced3f6f4d7aff8a4befbfa7124bd5ef66 100644 (file)
--- a/match_p.h
+++ b/match_p.h
@@ -432,7 +432,8 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
         int cont = 1;
         do {
             match = window + cur_match;
-            if (likely(memcmp(match+best_len-1, &scan_end, sizeof(scan_end)) != 0)) {
+            if (likely(memcmp(match+best_len-1, &scan_end, sizeof(scan_end)) != 0
+                || memcmp(match, &scan_start, sizeof(scan_start)) != 0)) {
                 if ((cur_match = prev[cur_match & wmask]) > limit
                     && --chain_length != 0) {
                     continue;
@@ -446,9 +447,6 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
         if (!cont)
             break;
 
-        if (memcmp(match, &scan_start, sizeof(scan_start)) != 0)
-            continue;
-
         /* It is not necessary to compare scan[2] and match[2] since they are
          * always equal when the other bytes match, given that the hash keys
          * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at