From: Rob Pike Date: Fri, 7 Jan 2011 22:41:33 +0000 (-0800) Subject: bytes.Buffer: Fix bug in UnreadByte. X-Git-Tag: weekly.2011-01-12~48 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=353fd1014c78b3b76fb5233f477677e0333e5f1a;p=gostls13.git bytes.Buffer: Fix bug in UnreadByte. Error check was inverted. Fixes #1396. R=rsc, adg CC=golang-dev https://golang.org/cl/3851042 --- diff --git a/src/pkg/bytes/buffer.go b/src/pkg/bytes/buffer.go index 55d3133868..2574b4f432 100644 --- a/src/pkg/bytes/buffer.go +++ b/src/pkg/bytes/buffer.go @@ -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