fix: SA4001 for net.UDPAddr copy

This commit is contained in:
wwqgtxx 2023-03-12 23:37:45 +08:00
parent 5de043acc6
commit 13111081be

View File

@ -46,7 +46,8 @@ func handleUDPToLocal(packet C.UDPPacket, pc net.PacketConn, key string, oAddr,
} }
fromUDPAddr := from.(*net.UDPAddr) fromUDPAddr := from.(*net.UDPAddr)
fromUDPAddr = &(*fromUDPAddr) // make a copy _fromUDPAddr := *fromUDPAddr
fromUDPAddr = &_fromUDPAddr // make a copy
if fromAddr, ok := netip.AddrFromSlice(fromUDPAddr.IP); ok { if fromAddr, ok := netip.AddrFromSlice(fromUDPAddr.IP); ok {
if fAddr.IsValid() && (oAddr.Unmap() == fromAddr.Unmap()) { if fAddr.IsValid() && (oAddr.Unmap() == fromAddr.Unmap()) {
fromUDPAddr.IP = fAddr.Unmap().AsSlice() fromUDPAddr.IP = fAddr.Unmap().AsSlice()