From 65f9ee2e071fb72816972f36adebadfcc3c47f26 Mon Sep 17 00:00:00 2001 From: ycc Date: Thu, 9 Nov 2023 22:50:51 +0100 Subject: [PATCH] out of bound errot detection --- client/serverlist.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/serverlist.go b/client/serverlist.go index fc71b4b..3eaf0f9 100644 --- a/client/serverlist.go +++ b/client/serverlist.go @@ -28,6 +28,9 @@ func (sl *ServerList) FilterByIdxs(MessageServerIdxs []int) (filtered *ServerLis // GetServerByIdx returns a server from it's index func (sl *ServerList) GetServerByIdx(idx int) (server *Server, err error) { + if idx > len(sl.Servers)-1 { + return nil, errors.New("requested server out of range of defined message servers") + } return &sl.Servers[idx], nil }