Fix to inflate: treat EOF as a character, as in the C code.

closes PR 13489.

In the C code, inflate is allowed to peek at least one character
beyond the extent of a deflated byte sequence.  The thread related to
the bug report of PR 13489 documents that deflate can peek beyond EOF.
This commit is contained in:
Danny Yoo 2013-02-04 23:45:08 -07:00
parent 31b66484b3
commit c6775cc060

View File

@ -278,7 +278,8 @@
(set! buf-pos MAX-LOOKAHEAD))
(let ([got (peek-bytes-avail! buffer buf-pos #f input-port buf-pos BUFFER-SIZE)])
(if (eof-object? got)
(error 'inflate "unexpected end of file")
(begin (bytes-set! buffer buf-pos 255)
(set! buf-max (add1 buf-pos)))
(set! buf-max (+ buf-pos got))))
(READBITS n))
(let ([v (bytes-ref buffer buf-pos)])