From: Nathan Moinvaziri Date: Thu, 14 May 2020 04:03:38 +0000 (-0400) Subject: Check distance in deflate_quick using MAX_DIST(s). X-Git-Tag: 1.9.9-b1~283 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81a06e1d5b335f70598fe4492b3f68c6690e5b50;p=thirdparty%2Fzlib-ng.git Check distance in deflate_quick using MAX_DIST(s). Added check_match to validate matches when using deflate_quick in debug mode. --- diff --git a/arch/x86/deflate_quick.c b/arch/x86/deflate_quick.c index 346b9d57f..26ce0befd 100644 --- a/arch/x86/deflate_quick.c +++ b/arch/x86/deflate_quick.c @@ -64,7 +64,7 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { hash_head = functable.quick_insert_string(s, s->strstart); dist = s->strstart - hash_head; - if (dist > 0 && (dist-1) < (s->w_size - 1)) { + if (dist > 0 && dist < MAX_DIST(s)) { match_len = functable.compare258(s->window + s->strstart, s->window + hash_head); if (match_len >= MIN_MATCH) { @@ -74,6 +74,8 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { if (match_len > MAX_MATCH) match_len = MAX_MATCH; + check_match(s, s->strstart, hash_head, match_len); + zng_tr_emit_dist(s, static_ltree, static_dtree, match_len - MIN_MATCH, dist); s->lookahead -= match_len; s->strstart += match_len;