From 84df403928e7e19116d8d9997e98c8ac66bf539b Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Sun, 22 Dec 2024 20:56:54 +0100 Subject: [PATCH] Properly use sync pools (pointers) --- client/firewall/uspfilter/conntrack/common.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/firewall/uspfilter/conntrack/common.go b/client/firewall/uspfilter/conntrack/common.go index 11d6599315d..a4b1971bf6e 100644 --- a/client/firewall/uspfilter/conntrack/common.go +++ b/client/firewall/uspfilter/conntrack/common.go @@ -110,7 +110,8 @@ func NewPreallocatedIPs() *PreallocatedIPs { return &PreallocatedIPs{ Pool: sync.Pool{ New: func() interface{} { - return make(net.IP, 16) + ip := make(net.IP, 16) + return &ip }, }, } @@ -118,12 +119,12 @@ func NewPreallocatedIPs() *PreallocatedIPs { // Get retrieves an IP from the pool func (p *PreallocatedIPs) Get() net.IP { - return p.Pool.Get().(net.IP) + return *p.Pool.Get().(*net.IP) } // Put returns an IP to the pool func (p *PreallocatedIPs) Put(ip net.IP) { - p.Pool.Put(ip) + p.Pool.Put(&ip) } // copyIP copies an IP address efficiently