From 62d2fac27cf388d6830ac1de1b64a54d2b52b3d5 Mon Sep 17 00:00:00 2001 From: Ian Luo <ian.luo@gmail.com> Date: Tue, 27 Oct 2020 15:49:55 +0800 Subject: [PATCH] add defensive check for client returned from selectSession --- remoting/getty/getty_client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 7c0c7c90d..7edc1cf8c 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -206,8 +206,10 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo // isAvailable returns true if the connection is available, or it can be re-established. func (c *Client) IsAvailable() bool { - _, _, err := c.selectSession(c.addr) - return err == nil + client, _, err := c.selectSession(c.addr) + return err == nil && + // defensive check + client != nil } func (c *Client) selectSession(addr string) (*gettyRPCClient, getty.Session, error) { -- GitLab