mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
tailcfg: don't panic on clone of nil RegisterRequest
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
dabeda21e0
commit
3e2a7de2e9
@ -635,6 +635,9 @@ type RegisterRequest struct {
|
|||||||
//
|
//
|
||||||
// TODO: extend cmd/cloner to generate this method.
|
// TODO: extend cmd/cloner to generate this method.
|
||||||
func (req *RegisterRequest) Clone() *RegisterRequest {
|
func (req *RegisterRequest) Clone() *RegisterRequest {
|
||||||
|
if req == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
res := new(RegisterRequest)
|
res := new(RegisterRequest)
|
||||||
*res = *req
|
*res = *req
|
||||||
if res.Hostinfo != nil {
|
if res.Hostinfo != nil {
|
||||||
|
@ -546,3 +546,11 @@ func TestDiscoKeyAppend(t *testing.T) {
|
|||||||
t.Errorf("got %q; want %q", got, want)
|
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…
Reference in New Issue
Block a user