Fix bugs exposed by testing.
authorChris Hanson <org/chris-hanson/cph>
Wed, 11 Jan 2017 03:36:33 +0000 (19:36 -0800)
committerChris Hanson <org/chris-hanson/cph>
Wed, 11 Jan 2017 03:36:33 +0000 (19:36 -0800)
src/runtime/binary-port.scm

index eeaa85b27a0e026dcb1836e2aa954d86b70d4d09..c129ea01de4a83bd66b51f07f960ea53348fb897 100644 (file)
@@ -104,13 +104,15 @@ USA.
     (make-binary-input-port
      (make-non-channel-input-source
       (lambda ()
-       (fix:< start end))
+       (fix:<= start end))
       (lambda (bv bs be)
-       (let ((n (fix:min (fix:- end start) (fix:- be bs))))
-         (let ((start* (fix:+ start n)))
-           (bytevector-copy! bv bs bytevector start start*)
-           (set! start start*))
-         n)))
+       (if (fix:< bs be)
+           (let ((n (fix:min (fix:- end start) (fix:- be bs))))
+             (let ((start* (fix:+ start n)))
+               (bytevector-copy! bv bs bytevector start start*)
+               (set! start start*))
+             n)
+           0)))
      'open-input-bytevector)))
 \f
 ;;;; Bytevector output ports