]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Check distance in deflate_quick using MAX_DIST(s).
authorNathan Moinvaziri <nathan@solidstatenetworks.com>
Thu, 14 May 2020 04:03:38 +0000 (00:03 -0400)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 25 May 2020 14:27:10 +0000 (16:27 +0200)
Added check_match to validate matches when using deflate_quick in debug mode.

arch/x86/deflate_quick.c

index 346b9d57f32ca44db551afc7fd50b280c0d3d028..26ce0befdc9207fff67f1bcebaa55907cf2bca77 100644 (file)
@@ -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;