Sometimes the channel can be nil - we shouldn't crash in this situation

This commit is contained in:
Ola Bini 2020-04-01 18:51:49 +00:00
parent c109af8d88
commit ebe189c524
No known key found for this signature in database
GPG key ID: 6786A150F6A2B28F

View file

@ -401,11 +401,13 @@ func (server *Server) handlerLoop() {
case vb := <-server.voicebroadcast:
if vb.target == 0 { // Current channel
channel := vb.client.Channel
for _, client := range channel.clients {
if client != vb.client {
err := client.SendUDP(vb.buf)
if err != nil {
client.Panicf("Unable to send UDP: %v", err)
if channel != nil {
for _, client := range channel.clients {
if client != vb.client {
err := client.SendUDP(vb.buf)
if err != nil {
client.Panicf("Unable to send UDP: %v", err)
}
}
}
}