mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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: 454ddad7df
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>
This commit is contained in:
parent
ef53de8ba4
commit
23b687eccb
2 changed files with 34 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue