From 2543d8bb2d60c9fcabfdedf666a08aaeb39fe5c4 Mon Sep 17 00:00:00 2001 From: R+ <30656734+nirui@users.noreply.github.com> Date: Thu, 25 Feb 2021 16:24:39 +0800 Subject: [PATCH] Close the UDPConn before returning if `setUDPSocketOptions` went wrong (#1227) Detail: https://github.com/miekg/dns/issues/1226 --- server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server.go b/server.go index eec02ef9..b2a63bda 100644 --- a/server.go +++ b/server.go @@ -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