mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes: fix UnreadByte failure after ReadBytes
Fixes #4583. R=golang-dev, minux.ma, bradfitz, rsc, dave CC=golang-dev https://golang.org/cl/6976050
This commit is contained in:
parent
9ae7f34084
commit
53e342f648
2 changed files with 24 additions and 1 deletions
|
|
@ -367,7 +367,7 @@ func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// readSlice is like readBytes but returns a reference to internal buffer data.
|
||||
// readSlice is like ReadBytes but returns a reference to internal buffer data.
|
||||
func (b *Buffer) readSlice(delim byte) (line []byte, err error) {
|
||||
i := IndexByte(b.buf[b.off:], delim)
|
||||
end := b.off + i + 1
|
||||
|
|
@ -377,6 +377,7 @@ func (b *Buffer) readSlice(delim byte) (line []byte, err error) {
|
|||
}
|
||||
line = b.buf[b.off:end]
|
||||
b.off = end
|
||||
b.lastRead = opRead
|
||||
return line, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue