From a3ea5d0f98825e209f4c659afd7e6896168962d9 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 10 Feb 2006 21:42:31 +0000 Subject: [PATCH] report unexpected EOF in inflate/gunzip svn: r2190 original commit: 144b8d65933db914ba0b58515e071e5757fdf5ee --- collects/mzlib/inflate.ss | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/collects/mzlib/inflate.ss b/collects/mzlib/inflate.ss index 4580311..0a80975 100644 --- a/collects/mzlib/inflate.ss +++ b/collects/mzlib/inflate.ss @@ -246,12 +246,14 @@ (define (NEEDBITS n) (when (< bk n) (let ([v (peek-byte input-port peeked)]) - (unless (eof-object? v) - (set! bb (+ bb (arithmetic-shift v bk))) - ;; assume that lookahead never needs more than 32 bytes: - (if (peeked . < . 32) - (set! peeked (add1 peeked)) - (read-byte input-port)))) + (if (eof-object? v) + (error 'inflate "unexpected end of file") + (begin + (set! bb (+ bb (arithmetic-shift v bk))) + ;; assume that lookahead never needs more than 32 bytes: + (if (peeked . < . 32) + (set! peeked (add1 peeked)) + (read-byte input-port))))) (set! bk (+ bk 8)) (NEEDBITS n))) (define (DUMPBITS n)