fix: check conn is nil in safeConnClose
This commit is contained in:
parent
bffb0573a6
commit
9711390c18
1 changed files with 2 additions and 2 deletions
|
@ -126,7 +126,7 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref
|
||||||
if !ip.IsValid() && fallback.IsValid() {
|
if !ip.IsValid() && fallback.IsValid() {
|
||||||
ip = fallback
|
ip = fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ func resolveUDPAddrWithPrefer(ctx context.Context, network, address string, pref
|
||||||
}
|
}
|
||||||
|
|
||||||
func safeConnClose(c net.Conn, err error) {
|
func safeConnClose(c net.Conn, err error) {
|
||||||
if err != nil {
|
if err != nil && c != nil {
|
||||||
_ = c.Close()
|
_ = c.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue