Close the UDPConn before returning if `setUDPSocketOptions` went wrong (#1227)

Detail: https://github.com/miekg/dns/issues/1226
This commit is contained in:
R+ 2021-02-25 16:24:39 +08:00 committed by GitHub
parent c08efdcc07
commit 2543d8bb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -321,6 +321,7 @@ func (srv *Server) ListenAndServe() error {
}
u := l.(*net.UDPConn)
if e := setUDPSocketOptions(u); e != nil {
u.Close()
return e
}
srv.PacketConn = l