From: cuiweixie Date: Tue, 27 Sep 2022 15:26:26 +0000 (+0800) Subject: bufio: use bytes.Clone X-Git-Tag: go1.20rc1~898 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=86ca550f407827f620e6c8314ec503fdb48dd898;p=gostls13.git bufio: use bytes.Clone Change-Id: Ic21d979da8be1a6047b9bcd65b5ee71ca2ef7548 Reviewed-on: https://go-review.googlesource.com/c/go/+/435278 Reviewed-by: Robert Griesemer Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- diff --git a/src/bufio/bufio.go b/src/bufio/bufio.go index 1da8ffa951..5a88def0c7 100644 --- a/src/bufio/bufio.go +++ b/src/bufio/bufio.go @@ -454,8 +454,7 @@ func (b *Reader) collectFragments(delim byte) (fullBuffers [][]byte, finalFragme } // Make a copy of the buffer. - buf := make([]byte, len(frag)) - copy(buf, frag) + buf := bytes.Clone(frag) fullBuffers = append(fullBuffers, buf) totalLen += len(buf) }