From ff65f6fa03cea888be1443036e38a6d28ef4e752 Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Tue, 9 Nov 2021 08:14:35 -0800 Subject: [PATCH] Fix: panic when spawning 10,000 bots :^) --- client.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client.go b/client.go index 45c4093..f770d83 100644 --- a/client.go +++ b/client.go @@ -519,6 +519,9 @@ func (c *Client) ConnSince() (since *time.Duration, err error) { // IsConnected returns true if the client is connected to the server. func (c *Client) IsConnected() bool { + if c == nil { + return false + } if c.conn == nil { return false } @@ -529,6 +532,9 @@ func (c *Client) IsConnected() bool { // GetNick returns the current nickname of the active connection. Panics if // tracking is disabled. func (c *Client) GetNick() string { + if c == nil { + return "" + } c.panicIfNotTracking() n := c.state.nick.Load().(string) @@ -788,6 +794,9 @@ func (c *Client) HasCapability(name string) (has bool) { // disabled. Adds useful info like what function specifically, and where it // was called from. func (c *Client) panicIfNotTracking() { + if c == nil { + return + } if !c.Config.disableTracking { return }