From a2ce5dbafdc5578f4fb9f32e7613f4ea09f81dd5 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 27 Feb 2012 08:34:26 -0500 Subject: [PATCH] fix zip/gzip bug Closes PR 12605 original commit: f9247ff3a5a772c8a314a4c9444e449c5b113053 --- collects/mzlib/deflate.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/collects/mzlib/deflate.rkt b/collects/mzlib/deflate.rkt index c8d443b..37b615c 100644 --- a/collects/mzlib/deflate.rkt +++ b/collects/mzlib/deflate.rkt @@ -469,7 +469,8 @@ (longest_match-loop))) (define (*++scan) (set! scanpos (add1 scanpos)) - (bytes-ref window-vec scanpos)) + (and (scanpos . < . window_size) ; the original C code can read past the end of the buffer + (bytes-ref window-vec scanpos))) (define (*++match) (set! matchpos (add1 matchpos)) (bytes-ref window-vec matchpos)) @@ -479,7 +480,7 @@ (eq? (*++scan) (*++match)) (eq? (*++scan) (*++match)) (eq? (*++scan) (*++match)) (eq? (*++scan) (*++match)) (eq? (*++scan) (*++match)) (eq? (*++scan) (*++match)) - (< scanpos strendpos)) + (< scanpos strendpos)) (match-eight))) (define (longest_match-loop)