mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 21:47: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
|
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.
|
- Fixed a bug where variables defined within `define-syntax` and `let-syntax` are reported as unbound by the compiler.
|
||||||
|
|
||||||
## 0.15 - February 26, 2020
|
## 0.15 - February 26, 2020
|
||||||
|
|
|
@ -715,16 +715,17 @@
|
||||||
(car _port)))
|
(car _port)))
|
||||||
(bv (make-bytevector k))
|
(bv (make-bytevector k))
|
||||||
(loop (lambda (n)
|
(loop (lambda (n)
|
||||||
|
(if (>= n k)
|
||||||
|
bv
|
||||||
(let ((b (read-u8 port)))
|
(let ((b (read-u8 port)))
|
||||||
(cond
|
(cond
|
||||||
((eof-object? b)
|
((eof-object? b)
|
||||||
(if (zero? n)
|
(if (zero? n)
|
||||||
b ;; EOF
|
b ;; EOF
|
||||||
(bytevector-copy bv 0 n)))
|
(bytevector-copy bv 0 n)))
|
||||||
((< n k)
|
(else
|
||||||
(bytevector-u8-set! bv n b)
|
(bytevector-u8-set! bv n b)
|
||||||
(loop (+ n 1)))
|
(loop (+ n 1)))))))))
|
||||||
(else bv))))))
|
|
||||||
(loop 0)))
|
(loop 0)))
|
||||||
(define (read-bytevector! vec . o)
|
(define (read-bytevector! vec . o)
|
||||||
(let* ((in (if (pair? o) (car o) (current-input-port)))
|
(let* ((in (if (pair? o) (car o) (current-input-port)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue