[NOD-952] Fix nil derefernce bug on outboundPeerConnectionFailed (#704)

This commit is contained in:
Ori Newman 2020-04-27 13:50:09 +03:00 committed by GitHub
parent 2910724b49
commit 3c89e1f7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -16,8 +16,7 @@ type Cursor interface {
Seek(key *Key) error
// Key returns the key of the current key/value pair, or ErrNotFound if done.
// Note that the key is trimmed to not include the prefix the cursor was opened
// with. The caller should not modify the contents of the returned slice, and
// The caller should not modify the contents of the returned key, and
// its contents may change on the next call to Next.
Key() (*Key, error)

View File

@ -1047,6 +1047,12 @@ func (s *Server) outboundPeerConnected(state *peerState, msg *outboundPeerConnec
// outboundPeerConnected is invoked by the connection manager when a new
// outbound connection failed to be established.
func (s *Server) outboundPeerConnectionFailed(msg *outboundPeerConnectionFailedMsg) {
// If the connection request has no address
// associated to it, do nothing.
if msg.connReq.Addr == nil {
return
}
host, portStr, err := net.SplitHostPort(msg.connReq.Addr.String())
if err != nil {
srvrLog.Debugf("Cannot extract address host and port %s: %s", msg.connReq.Addr, err)