From cdbc9002f37e57fffe55d2f0dd1173e75985ea51 Mon Sep 17 00:00:00 2001 From: Hans Kristian Rosbach Date: Sun, 11 Aug 2019 18:55:14 +0200 Subject: [PATCH] Move scan_start check, based on Cloudflare commit 5f1bd2b72e5966aa8a4f942e6e8050a050161cf9 --- match_p.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/match_p.h b/match_p.h index 776d6cec..363c7a3c 100644 --- 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 -- 2.47.2