summaryrefslogtreecommitdiff
path: root/deflate_fast.c
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2021-03-18 14:54:46 +0100
committerHans Kristian Rosbach <hk-github@circlestorm.org>2021-03-20 23:35:48 +0100
commitf426ac9db3e0ce35c83838aa8eaf248b2b624d0a (patch)
treea79814c5409f3dacff828d8c72f1df03e686bf7b /deflate_fast.c
parentbc33b26ca5391eb6b2c952cd032920033be27a53 (diff)
Restore hash_head != 0 checks
Commit bc5915e2dec7 ("Fixed unsigned integer overflow ASAN error when hash_head > s->strstart.") removed hash_head != 0 checks in fast, medium and slow deflate, because it improved performance [1]. Unfortunately, the attached test started failing after that. Apparently, as the comments suggest, the code implicitly relies on matches with the beginning of the window being skipped. So restore the check. [1] https://github.com/zlib-ng/zlib-ng/pull/772#issuecomment-710760300
Diffstat (limited to 'deflate_fast.c')
-rw-r--r--deflate_fast.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/deflate_fast.c b/deflate_fast.c
index 14718ba..1594886 100644
--- a/deflate_fast.c
+++ b/deflate_fast.c
@@ -48,7 +48,7 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
* At this point we have always match length < MIN_MATCH
*/
- if (dist <= MAX_DIST(s) && dist > 0) {
+ if (dist <= MAX_DIST(s) && dist > 0 && hash_head != 0) {
/* To simplify the code, we prevent matches with the string
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).