Commit 353fd101 authored by Rob Pike's avatar Rob Pike

bytes.Buffer: Fix bug in UnreadByte.

Error check was inverted.

Fixes #1396.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/3851042
parent 9d634e50
......@@ -291,7 +291,7 @@ func (b *Buffer) UnreadRune() os.Error {
// read operation. If write has happened since the last read, UnreadByte
// returns an error.
func (b *Buffer) UnreadByte() os.Error {
if b.lastRead == opReadRune || b.lastRead == opRead {
if b.lastRead != opReadRune && b.lastRead != opRead {
return os.ErrorString("bytes.Buffer: UnreadByte: previous operation was not a read")
}
b.lastRead = opInvalid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment