]> Cypherpunks repositories - gostls13.git/commitdiff
net/textproto: use bytes.Clone
authorcuiweixie <cuiweixie@gmail.com>
Tue, 27 Sep 2022 16:31:44 +0000 (00:31 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 28 Sep 2022 03:55:14 +0000 (03:55 +0000)
Change-Id: Ic73d667a98df3f2d1705a67e7e8625c6ba65cc0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/435284
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

src/net/textproto/reader.go

index 1f7afc57665cda029990358aea342a1dc6150707..1cae6ba1e690d43d82181701b68602771e6d8bb7 100644 (file)
@@ -42,9 +42,7 @@ func (r *Reader) ReadLine() (string, error) {
 func (r *Reader) ReadLineBytes() ([]byte, error) {
        line, err := r.readLineSlice()
        if line != nil {
-               buf := make([]byte, len(line))
-               copy(buf, line)
-               line = buf
+               line = bytes.Clone(line)
        }
        return line, err
 }
@@ -111,9 +109,7 @@ func trim(s []byte) []byte {
 func (r *Reader) ReadContinuedLineBytes() ([]byte, error) {
        line, err := r.readContinuedLineSlice(noValidation)
        if line != nil {
-               buf := make([]byte, len(line))
-               copy(buf, line)
-               line = buf
+               line = bytes.Clone(line)
        }
        return line, err
 }