tailcfg: don't panic on clone of nil RegisterRequest

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/2844/head
Brad Fitzpatrick 3 years ago committed by Brad Fitzpatrick
parent dabeda21e0
commit 3e2a7de2e9

@ -635,6 +635,9 @@ type RegisterRequest struct {
//
// TODO: extend cmd/cloner to generate this method.
func (req *RegisterRequest) Clone() *RegisterRequest {
if req == nil {
return nil
}
res := new(RegisterRequest)
*res = *req
if res.Hostinfo != nil {

@ -546,3 +546,11 @@ func TestDiscoKeyAppend(t *testing.T) {
t.Errorf("got %q; want %q", got, want)
}
}
func TestRegisterRequestNilClone(t *testing.T) {
var nilReq *RegisterRequest
got := nilReq.Clone()
if got != nil {
t.Errorf("got = %v; want nil", got)
}
}

Loading…
Cancel
Save