mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 13:37:33 +02:00
Prevent read-bytevector from corrupting data
Previously it was possible for an extra by to be introduced between multiple reads
This commit is contained in:
parent
f2bf308746
commit
b5a9bd24e1
2 changed files with 12 additions and 12 deletions
|
@ -14,8 +14,7 @@ Features
|
|||
|
||||
Bug Fixes
|
||||
|
||||
- WIP - bug fixes to `read-bytevector` (return EOF, issue with sha2 sums)
|
||||
|
||||
- Fixed a bug in `read-bytevector` where an extra byte could be introduced when reading multiple chunks of data.
|
||||
- Fixed a bug where variables defined within `define-syntax` and `let-syntax` are reported as unbound by the compiler.
|
||||
|
||||
## 0.15 - February 26, 2020
|
||||
|
|
|
@ -715,16 +715,17 @@
|
|||
(car _port)))
|
||||
(bv (make-bytevector k))
|
||||
(loop (lambda (n)
|
||||
(let ((b (read-u8 port)))
|
||||
(cond
|
||||
((eof-object? b)
|
||||
(if (zero? n)
|
||||
b ;; EOF
|
||||
(bytevector-copy bv 0 n)))
|
||||
((< n k)
|
||||
(bytevector-u8-set! bv n b)
|
||||
(loop (+ n 1)))
|
||||
(else bv))))))
|
||||
(if (>= n k)
|
||||
bv
|
||||
(let ((b (read-u8 port)))
|
||||
(cond
|
||||
((eof-object? b)
|
||||
(if (zero? n)
|
||||
b ;; EOF
|
||||
(bytevector-copy bv 0 n)))
|
||||
(else
|
||||
(bytevector-u8-set! bv n b)
|
||||
(loop (+ n 1)))))))))
|
||||
(loop 0)))
|
||||
(define (read-bytevector! vec . o)
|
||||
(let* ((in (if (pair? o) (car o) (current-input-port)))
|
||||
|
|
Loading…
Add table
Reference in a new issue