Pull request: dnsforward: fix closing of uninitialized ipset ctx

Merge in DNS/adguard-home from fix-close to master

Squashed commit of the following:

commit 43b55105cc669e2740ef178808c81a22c8f53cc1
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Feb 1 19:19:12 2021 +0300

    dnsforward: fix closing of uninitialized ipset ctx
This commit is contained in:
Ainar Garipov 2021-02-01 19:33:45 +03:00
parent 3e0238aa99
commit 8fdd021ed7
1 changed files with 10 additions and 6 deletions

View File

@ -192,15 +192,19 @@ func (c *ipsetCtx) init(ipsetConfig []string) (err error) {
// Close closes the Linux Netfilter connections.
func (c *ipsetCtx) Close() (err error) {
var errors []error
if c.ipv4Conn != nil {
err = c.ipv4Conn.Close()
if err != nil {
errors = append(errors, err)
}
}
if c.ipv6Conn != nil {
err = c.ipv6Conn.Close()
if err != nil {
errors = append(errors, err)
}
}
if len(errors) != 0 {
return agherr.Many("closing ipsets", errors...)