server: avoid nil pointer deference within OutboundPeerConnected
This commit is contained in:
parent
06ff0a0192
commit
c4e43dbaa2
10
server.go
10
server.go
@ -960,7 +960,9 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
|
|||||||
// entry for this peer from the map.
|
// entry for this peer from the map.
|
||||||
if connReqs, ok := s.persistentConnReqs[pubStr]; ok {
|
if connReqs, ok := s.persistentConnReqs[pubStr]; ok {
|
||||||
for _, pConnReq := range connReqs {
|
for _, pConnReq := range connReqs {
|
||||||
if pConnReq.ID() != connReq.ID() {
|
if connReq != nil &&
|
||||||
|
pConnReq.ID() != connReq.ID() {
|
||||||
|
|
||||||
s.connMgr.Remove(pConnReq.ID())
|
s.connMgr.Remove(pConnReq.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -977,7 +979,11 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
|
|||||||
srvrLog.Warnf("Established outbound connection to "+
|
srvrLog.Warnf("Established outbound connection to "+
|
||||||
"peer %x, but already connected, dropping conn",
|
"peer %x, but already connected, dropping conn",
|
||||||
nodePub.SerializeCompressed())
|
nodePub.SerializeCompressed())
|
||||||
s.connMgr.Remove(connReq.ID())
|
|
||||||
|
if connReq != nil {
|
||||||
|
s.connMgr.Remove(connReq.ID())
|
||||||
|
}
|
||||||
|
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user