aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/buffer.go
diff options
context:
space:
mode:
authorDave Russell <forfuncsake@gmail.com>2018-05-19 00:54:43 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-05-29 19:46:33 +0000
commit23b687eccbcc68f44acf34fd5971f0f5c04d90de (patch)
tree5fc7f99aebdc3c74a9580bcc4ee39cc23b9f6b8d /src/bytes/buffer.go
parentef53de8ba4d774e4eedb04192a9f03f28a9652e8 (diff)
downloadgo-23b687eccbcc68f44acf34fd5971f0f5c04d90de.tar.xz
bytes: re-slice buffer to its previous length after call to grow()
Fixes #25435 The added test fails without the re-slice and passes with it. Change-Id: I5ebc2a737285eb116ecc5938d8bf49050652830f GitHub-Last-Rev: 454ddad7df8d56a1d0e05a999ed8277c5516ce01 GitHub-Pull-Request: golang/go#25436 Reviewed-on: https://go-review.googlesource.com/113495 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/bytes/buffer.go')
-rw-r--r--src/bytes/buffer.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/bytes/buffer.go b/src/bytes/buffer.go
index dc9d5e95d3..a2eca2ed12 100644
--- a/src/bytes/buffer.go
+++ b/src/bytes/buffer.go
@@ -202,6 +202,7 @@ func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
b.lastRead = opInvalid
for {
i := b.grow(MinRead)
+ b.buf = b.buf[:i]
m, e := r.Read(b.buf[i:cap(b.buf)])
if m < 0 {
panic(errNegativeRead)