diff options
author | Ilya Leoshkevich <iii@linux.ibm.com> | 2021-03-18 14:54:46 +0100 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2021-03-20 23:35:48 +0100 |
commit | f426ac9db3e0ce35c83838aa8eaf248b2b624d0a (patch) | |
tree | a79814c5409f3dacff828d8c72f1df03e686bf7b /deflate_slow.c | |
parent | bc33b26ca5391eb6b2c952cd032920033be27a53 (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_slow.c')
-rw-r--r-- | deflate_slow.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/deflate_slow.c b/deflate_slow.c index cac8a96..dc1c072 100644 --- a/deflate_slow.c +++ b/deflate_slow.c @@ -50,7 +50,7 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) { match_len = MIN_MATCH-1; dist = (int64_t)s->strstart - hash_head; - if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match) { + if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match && 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). |