Permalink
Browse files

ユニフォームベクタポートの挙動に起因するバグを修正

EOFに達していないユニフォームベクタポート(buffered-input-port)からread-block!を
使用して0バイトを読み込む場合の返り値が通常のポート(0を返す)と違いEOFを返すようです。
  • Loading branch information...
1 parent 4f9fd75 commit 5f4dbe8ccadb79ae439b986502f7e7919dbc66a2 @ayatoy committed May 3, 2012
Showing with 10 additions and 8 deletions.
  1. +10 −8 mongo/bson.scm
View
@@ -270,14 +270,16 @@
vals))
(define (read-nbyte-to-u8vector n iport)
- (let* ([u8v (make-u8vector n)]
- [res (read-block! u8v iport)])
- (cond
- [(eof-object? res)
- (error <bson-read-error> :reason #f "unexpected EOF")]
- [(not (= n res))
- (errorf <bson-read-error> :reason #f "expected ~s byte: ~s" n res)]
- [else u8v])))
+ (if (= n 0)
+ #u8()
+ (let* ([u8v (make-u8vector n)]
+ [res (read-block! u8v iport)])
+ (cond
+ [(eof-object? res)
+ (error <bson-read-error> :reason #f "unexpected EOF")]
+ [(not (= n res))
+ (errorf <bson-read-error> :reason #f "expected ~s byte: ~s" n res)]
+ [else u8v]))))
;;;; int32

0 comments on commit 5f4dbe8

Please sign in to comment.