cherry-pick: 3987 Fix nil pointer dereference
Merge in DNS/adguard-home from 3987-fix-nil-deref to master Updates #3987. Updates #2846. Squashed commit of the following: commit d653e09ce88a8b10b2a17fea1563c419895c714c Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 20:08:51 2021 +0300 all: log changes commit c47a4eeacf76fa7df2d01af166dee9d52528ac58 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 19:22:39 2021 +0300 aghnet: fix windows tests commit 9c91f14ccfe967ada3c00ddb86d673238e52c12d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 19:09:49 2021 +0300 aghnet: imp code readability, docs commit d3df15d1892e4ebfe7f8ea7144e39a0c712fce52 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Dec 23 18:47:28 2021 +0300 aghnet: fix nil pointer dereference
This commit is contained in:
committed by
Ainar Garipov
parent
d280151c18
commit
7528699fc2
@@ -187,7 +187,8 @@ func GetSubnet(ifaceName string) *net.IPNet {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckPort checks if the port is available for binding.
|
||||
// CheckPort checks if the port is available for binding. network is expected
|
||||
// to be one of "udp" and "tcp".
|
||||
func CheckPort(network string, ip net.IP, port int) (err error) {
|
||||
var c io.Closer
|
||||
addr := netutil.IPPort{IP: ip, Port: port}.String()
|
||||
@@ -200,7 +201,11 @@ func CheckPort(network string, ip net.IP, port int) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.WithDeferred(err, closePortChecker(c))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return closePortChecker(c)
|
||||
}
|
||||
|
||||
// IsAddrInUse checks if err is about unsuccessful address binding.
|
||||
|
||||
Reference in New Issue
Block a user