From 0d76f9daeb8733dde33124a61878ea0106aec92f Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Mon, 18 Mar 2024 10:49:33 +0800 Subject: [PATCH] bug: fix the memory leaks of localAddr and localAddr in conn Fixes #546 --- connection_unix.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connection_unix.go b/connection_unix.go index b31234af4..4f9a45fa5 100644 --- a/connection_unix.go +++ b/connection_unix.go @@ -85,8 +85,6 @@ func newUDPConn(fd int, el *eventloop, localAddr net.Addr, sa unix.Sockaddr, con func (c *conn) release() { c.ctx = nil - c.localAddr = nil - c.remoteAddr = nil c.buffer = nil if addr, ok := c.localAddr.(*net.TCPAddr); ok && c.localAddr != c.loop.ln.addr && len(addr.Zone) > 0 { bsPool.Put(bs.StringToBytes(addr.Zone)) @@ -94,6 +92,8 @@ func (c *conn) release() { if addr, ok := c.remoteAddr.(*net.TCPAddr); ok && len(addr.Zone) > 0 { bsPool.Put(bs.StringToBytes(addr.Zone)) } + c.localAddr = nil + c.remoteAddr = nil c.pollAttachment.FD, c.pollAttachment.Callback = 0, nil if !c.isDatagram { c.opened = false