out of bound errot detection
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ycc 2023-11-09 22:50:51 +01:00
parent eeb39338e2
commit 65f9ee2e07

View File

@ -28,6 +28,9 @@ func (sl *ServerList) FilterByIdxs(MessageServerIdxs []int) (filtered *ServerLis
// GetServerByIdx returns a server from it's index // GetServerByIdx returns a server from it's index
func (sl *ServerList) GetServerByIdx(idx int) (server *Server, err error) { 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 return &sl.Servers[idx], nil
} }