fix: handle nil pointer stored in non-nil interface (#2337)

This commit is contained in:
Restia-Ashbell
2025-11-02 20:02:16 +08:00
committed by wwqgtxx
parent 99e68e9983
commit 6fb1f796a5
2 changed files with 8 additions and 3 deletions

View File

@@ -252,13 +252,14 @@ func (spc *ssrPacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr
return nil, nil, nil, errors.New("parse addr error")
}
addr = _addr.UDPAddr()
if addr == nil {
udpAddr := _addr.UDPAddr()
if udpAddr == nil {
if put != nil {
put()
}
return nil, nil, nil, errors.New("parse addr error")
}
addr = udpAddr
data = data[len(_addr):]
return

View File

@@ -183,7 +183,11 @@ func (pc *PacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr, er
if err != nil {
return nil, nil, nil, err
}
addr = destination.UDPAddr()
udpAddr := destination.UDPAddr()
if udpAddr == nil {
return nil, nil, nil, errors.New("parse addr error")
}
addr = udpAddr
data = pool.Get(pool.UDPBufferSize)
put = func() {