lib/stun: Prevent nil deref when naming service (#7872)
This commit is contained in:
+7
-1
@@ -107,8 +107,14 @@ func New(cfg config.Wrapper, subscriber Subscriber, conn *net.UDPConn) (*Service
|
|||||||
client.SetSoftwareName("") // Explicitly unset this, seems to freak some servers out.
|
client.SetSoftwareName("") // Explicitly unset this, seems to freak some servers out.
|
||||||
|
|
||||||
// Return the service and the other conn to the client
|
// Return the service and the other conn to the client
|
||||||
|
name := "Stun@"
|
||||||
|
if local := conn.LocalAddr(); local != nil {
|
||||||
|
name += local.Network() + "://" + local.String()
|
||||||
|
} else {
|
||||||
|
name += "unknown"
|
||||||
|
}
|
||||||
s := &Service{
|
s := &Service{
|
||||||
name: "Stun@" + conn.LocalAddr().Network() + "://" + conn.LocalAddr().String(),
|
name: name,
|
||||||
|
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
subscriber: subscriber,
|
subscriber: subscriber,
|
||||||
|
|||||||
Reference in New Issue
Block a user