From 96987b2861ea12ec2fc20fd8be420e635c68638b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 7 Dec 2006 23:53:00 +0000 Subject: [PATCH] * deflate.c (deflate_fast, deflate): Avoid core dump. Problem originally reported by Jochen Friedrich and trivial patch supplied by Anthony Towns; see . --- ChangeLog | 6 ++++++ deflate.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1806ed..ca09d76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-12-07 Paul Eggert + + * deflate.c (deflate_fast, deflate): Avoid core dump. Problem + originally reported by Jochen Friedrich and trivial patch supplied + by Anthony Towns; see . + 2006-12-06 Paul Eggert * NEWS, configure.ac (AC_INIT): diff --git a/deflate.c b/deflate.c index 232f4a7..32d361e 100644 --- a/deflate.c +++ b/deflate.c @@ -607,7 +607,8 @@ local off_t deflate_fast() /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ - if (hash_head != NIL && strstart - hash_head <= MAX_DIST) { + if (hash_head != NIL && strstart - hash_head <= MAX_DIST + && strstart <= window_size - MIN_LOOKAHEAD) { /* 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). @@ -695,7 +696,8 @@ off_t deflate() match_length = MIN_MATCH-1; if (hash_head != NIL && prev_length < max_lazy_match && - strstart - hash_head <= MAX_DIST) { + strstart - hash_head <= MAX_DIST && + strstart <= window_size - MIN_LOOKAHEAD) { /* 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). -- 2.47.2