From f61460725f1224f7e669b0f6dfd4c4224012c508 Mon Sep 17 00:00:00 2001 From: Maksim Kovshov Date: Tue, 30 Jan 2024 13:26:57 +0300 Subject: [PATCH] fix insurance, check that the object is still active before disconnecting panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x138a3ae] goroutine 1 [running]: github.com/stmcginnis/gofish.(*APIClient).Logout(0x0?) /Users/max/Desktop/code/device-mgr/vendor/github.com/stmcginnis/gofish/client.go:576 +0xe panic({0x13e4040?, 0x1812cf0?}) --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index c2d709a4..0e183532 100644 --- a/client.go +++ b/client.go @@ -573,7 +573,7 @@ func (c *APIClient) dumpResponse(resp *http.Response) error { // Logout will delete any active session. Useful to defer logout when creating // a new connection. func (c *APIClient) Logout() { - if c.Service != nil && c.auth != nil { + if c != nil && c.Service != nil && c.auth != nil { _ = c.Service.DeleteSession(c.auth.Session) } }