Fix: mutable SplitAddr cause panic

This commit is contained in:
Dreamacro
2020-03-02 23:47:23 +08:00
parent 23525ecc15
commit e57a13ed7a
2 changed files with 14 additions and 2 deletions

View File

@ -216,6 +216,11 @@ func (spc *ssPacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
return 0, nil, errors.New("parse addr error")
}
udpAddr := addr.UDPAddr()
if udpAddr == nil {
return 0, nil, errors.New("parse addr error")
}
copy(b, b[len(addr):])
return n - len(addr), addr.UDPAddr(), e
return n - len(addr), udpAddr, e
}