]> Cypherpunks repositories - gostls13.git/commitdiff
bytes.Buffer: Fix bug in UnreadByte.
authorRob Pike <r@golang.org>
Fri, 7 Jan 2011 22:41:33 +0000 (14:41 -0800)
committerRob Pike <r@golang.org>
Fri, 7 Jan 2011 22:41:33 +0000 (14:41 -0800)
Error check was inverted.

Fixes #1396.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/3851042

src/pkg/bytes/buffer.go

index 55d313386856f9b9c0b0cc77d5587aac680ebf67..2574b4f4329852383f2212d51b8ea8e3fb79090c 100644 (file)
@@ -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