summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
authorNathan Moinvaziri <nathan@nathanm.com>2020-06-02 09:17:56 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2020-06-08 21:16:31 +0200
commitbf01f6b9ea4b2095de7d3d456fd5963f1e8fe05f (patch)
tree913006ca532f0596d311d18e82d03625f2f5f70d /deflate.c
parent8095fa71f0187c99bfbb364c99b563ecf57eadb9 (diff)
Move check for match length in deflate_quick to check_match.
Diffstat (limited to 'deflate.c')
-rw-r--r--deflate.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/deflate.c b/deflate.c
index 46f0516..2a32c91 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);