diff --git a/implementations/racket/preserves/preserves/read-binary.rkt b/implementations/racket/preserves/preserves/read-binary.rkt index 2b046d1..6edcb1c 100644 --- a/implementations/racket/preserves/preserves/read-binary.rkt +++ b/implementations/racket/preserves/preserves/read-binary.rkt @@ -99,10 +99,10 @@ (define (next-varint) (eof-guard (read-varint in-port))) (define (next-integer n) - (when (zero? n) (return (on-fail "Zero-length integer not permitted"))) - (define acc0 (next-byte)) - (define acc (if (< acc0 128) acc0 (- acc0 256))) - (for/fold [(acc acc)] [(n (in-range (- n 1)))] (+ (* acc 256) (next-byte)))) + (cond [(zero? n) 0] + [else (define acc0 (next-byte)) + (define acc (if (< acc0 128) acc0 (- acc0 256))) + (for/fold [(acc acc)] [(n (in-range (- n 1)))] (+ (* acc 256) (next-byte)))])) (define (next-items) (define pos0 (pos))