crypto/tls: make config.Clone return nil if the source is nil

Fixes #40565

Change-Id: I13a67be193f8cd68df02b8729529e627a73d364b
GitHub-Last-Rev: b03d2c04fd88db909b40dfd7bd08fe13d8994ab9
GitHub-Pull-Request: golang/go#40566
Reviewed-on: https://go-review.googlesource.com/c/go/+/246637
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Chen.Zhidong 2020-09-29 09:05:41 +00:00 committed by Filippo Valsorda
parent c6334279e3
commit d49768001b
2 changed files with 11 additions and 1 deletions

View file

@ -841,6 +841,13 @@ func TestCloneNonFuncFields(t *testing.T) {
}
}
func TestCloneNilConfig(t *testing.T) {
var config *Config
if cc := config.Clone(); cc != nil {
t.Fatalf("Clone with nil should return nil, got: %+v", cc)
}
}
// changeImplConn is a net.Conn which can change its Write and Close
// methods.
type changeImplConn struct {