* deflate.c (deflate_fast, deflate): Avoid core dump. Problem
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Dec 2006 23:53:00 +0000 (23:53 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Dec 2006 23:53:00 +0000 (23:53 +0000)
originally reported by Jochen Friedrich and trivial patch supplied
by Anthony Towns; see <http://bugs.debian.org/184057>.

ChangeLog
deflate.c

index b1806edbad39bf8737f1fa4b4dc6c2a90fa634c9..ca09d7641347eb01969b074788b9d54aefbdc0a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * deflate.c (deflate_fast, deflate): Avoid core dump.  Problem
+       originally reported by Jochen Friedrich and trivial patch supplied
+       by Anthony Towns; see <http://bugs.debian.org/184057>.
+
 2006-12-06  Paul Eggert  <eggert@cs.ucla.edu>
 
        * NEWS, configure.ac (AC_INIT):
index 232f4a7b98494684743fcadf6c8985b20bee609b..32d361eff6600d1eb928adbd162534430ff4b073 100644 (file)
--- 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).