diff --git a/pkgs/racket-test-core/tests/racket/rx.rktl b/pkgs/racket-test-core/tests/racket/rx.rktl index 1b19cf8578..077bd52915 100644 --- a/pkgs/racket-test-core/tests/racket/rx.rktl +++ b/pkgs/racket-test-core/tests/racket/rx.rktl @@ -1605,6 +1605,19 @@ (#"^(E)?(?(1)aa|a)*$" #"aaa" (#"aaa" #f)) (#"^(E)?(?(1)aa|a)*$" #"aaaa" (#"aaaa" #f)))) + +(let () + (define out (open-output-bytes)) + (define infinite-voids + (make-input-port + 'voids + (lambda (s) (lambda args 'void)) + (lambda (skip s evt) (lambda args 'void)) + void)) + (err/rt-test (regexp-match #rx"." infinite-voids) + exn:fail:contract? + #rx"non-character in an unsupported context")) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Test unicode-property patterns diff --git a/pkgs/racket-test/tests/file/unzip.rkt b/pkgs/racket-test/tests/file/unzip.rkt index 7cfeddc775..ddba603fc2 100644 --- a/pkgs/racket-test/tests/file/unzip.rkt +++ b/pkgs/racket-test/tests/file/unzip.rkt @@ -1,5 +1,6 @@ #lang racket/base (require file/unzip + file/gunzip racket/runtime-path racket/port tests/eli-tester) @@ -27,7 +28,18 @@ (call-with-input-file* unzip-me.zip test-with-unzip) (call-with-input-file* unzip-me.zip (lambda(in_port) (test-with-unzip (input-port-append #f in_port)))) - (test-with-unzip-entry)) + (test-with-unzip-entry) + + (test (let () + (define out (open-output-bytes)) + (define infinite-voids + (make-input-port + 'voids + (lambda (s) (lambda args 'void)) + (lambda (skip s evt) (lambda args 'void)) + void)) + (inflate infinite-voids out)) + =error> "non-character in an unsupported context")) (provide tests) (module+ main (tests)) diff --git a/racket/collects/file/gunzip.rkt b/racket/collects/file/gunzip.rkt index 8732da0962..01d64155df 100644 --- a/racket/collects/file/gunzip.rkt +++ b/racket/collects/file/gunzip.rkt @@ -288,13 +288,18 @@ (set! buf-pos (min MAX-LOOKAHEAD buf-max))) ;; Peek (not read) some available bytes: (let ([got (peek-bytes-avail! buffer buf-pos #f input-port buf-pos BUFFER-SIZE)]) - (if (eof-object? got) - ;; Treat an EOF as a -1 "byte": - (begin - (bytes-set! buffer buf-pos 255) - (set! buf-max (add1 buf-pos))) - ;; Got normal bytes: - (set! buf-max (+ buf-pos got)))) + (cond + [(eof-object? got) + ;; Treat an EOF as a -1 "byte": + (bytes-set! buffer buf-pos 255) + (set! buf-max (add1 buf-pos))] + [(fixnum? got) + ;; Got normal bytes: + (set! buf-max (+ buf-pos got))] + [else + (raise-arguments-error 'inflate + "non-character in an unsupported context" + "port" input-port)])) (READBITS n)) (let ([v (bytes-ref buffer buf-pos)]) (set! buf-pos (add1 buf-pos)) diff --git a/racket/src/cs/schemified/regexp.scm b/racket/src/cs/schemified/regexp.scm index e0b043cba3..70735b2ca8 100644 --- a/racket/src/cs/schemified/regexp.scm +++ b/racket/src/cs/schemified/regexp.scm @@ -5028,13 +5028,19 @@ len_0)))))) (if (eof-object? n_0) #f - (if (zero? n_0) - (begin (set-lazy-bytes-failed?! s_0 #t) #f) - (begin - (set-lazy-bytes-end! - s_0 - (+ n_0 len_0 discarded-count_0)) - #t)))) + (if (not (fixnum? n_0)) + (raise-arguments-error + 'regexp-match + "non-character in an unsupported context" + "port" + (lazy-bytes-in s_0)) + (if (zero? n_0) + (begin (set-lazy-bytes-failed?! s_0 #t) #f) + (begin + (set-lazy-bytes-end! + s_0 + (+ n_0 len_0 discarded-count_0)) + #t))))) (let ((max-peek_0 (lazy-bytes-max-peek s_0))) (let ((prefix-len_0 (if max-peek_0 (lazy-bytes-prefix-len s_0) #f))) diff --git a/racket/src/regexp/match/lazy-bytes.rkt b/racket/src/regexp/match/lazy-bytes.rkt index afdd36357b..4e11226087 100644 --- a/racket/src/regexp/match/lazy-bytes.rkt +++ b/racket/src/regexp/match/lazy-bytes.rkt @@ -113,6 +113,10 @@ len)) (cond [(eof-object? n) #f] + [(not (fixnum? n)) + (raise-arguments-error 'regexp-match + "non-character in an unsupported context" + "port" (lazy-bytes-in s))] [(zero? n) ;; would block or progress evt became ready (set-lazy-bytes-failed?! s #t)