From acc5e3a0c20432199181fef2bc6204fbd11d21d0 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Wed, 28 Sep 2022 00:31:44 +0800 Subject: [PATCH] net/textproto: use bytes.Clone Change-Id: Ic73d667a98df3f2d1705a67e7e8625c6ba65cc0a Reviewed-on: https://go-review.googlesource.com/c/go/+/435284 Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Auto-Submit: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov --- src/net/textproto/reader.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/net/textproto/reader.go b/src/net/textproto/reader.go index 1f7afc5766..1cae6ba1e6 100644 --- a/src/net/textproto/reader.go +++ b/src/net/textproto/reader.go @@ -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 } -- 2.50.0