Fix nil dereference when network is specified in username

This commit is contained in:
Simon Ser 2020-03-12 18:21:41 +01:00
parent 2dfbbf18fd
commit 461de13ecc
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -335,9 +335,10 @@ func (dc *downstreamConn) register() error {
return errAuthFailed
}
var network *network
if networkName != "" {
dc.network = dc.user.getNetwork(networkName)
if dc.network == nil {
network = u.getNetwork(networkName)
if network == nil {
dc.logger.Printf("failed registration: unknown network %q", networkName)
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
@ -350,6 +351,7 @@ func (dc *downstreamConn) register() error {
dc.registered = true
dc.user = u
dc.network = network
u.lock.Lock()
firstDownstream := len(u.downstreamConns) == 0