From: Nathan Moinvaziri Date: Tue, 2 Jun 2020 16:17:56 +0000 (-0700) Subject: Move check for match length in deflate_quick to check_match. X-Git-Tag: 1.9.9-b1~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf01f6b9ea4b2095de7d3d456fd5963f1e8fe05f;p=thirdparty%2Fzlib-ng.git Move check for match length in deflate_quick to check_match. --- diff --git a/deflate.c b/deflate.c index 46f05165..2a32c917 100644 --- a/deflate.c +++ b/deflate.c @@ -1216,6 +1216,11 @@ static void lm_init(deflate_state *s) { * Check that the match at match_start is indeed a match. */ void check_match(deflate_state *s, Pos start, Pos match, int length) { + /* check that the match length is valid*/ + if (length < MIN_MATCH || length > MAX_MATCH) { + fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); + z_error("invalid match length"); + } /* check that the match is indeed a match */ if (memcmp(s->window + match, s->window + start, length) != EQUAL) { fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); diff --git a/deflate_quick.c b/deflate_quick.c index cd79af4f..70a7e345 100644 --- a/deflate_quick.c +++ b/deflate_quick.c @@ -68,9 +68,6 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { if (match_len > s->lookahead) match_len = s->lookahead; - 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);