Fix out of range access when requesting last page with list
Prevent command `list` from failing with out of range access error if number of entries is lower than maximum entry index for that page a.k.a. if `len(result) < page*max`
This commit is contained in:
parent
91bb38eaa3
commit
daee58bece
1 changed files with 5 additions and 1 deletions
|
@ -609,7 +609,11 @@ func (handler *CommandHandler) CommandList(ce *CommandEvent) {
|
|||
}
|
||||
return
|
||||
}
|
||||
result = result[(page-1)*max : page*max]
|
||||
lastIndex := page*max
|
||||
if lastIndex > len(result) {
|
||||
lastIndex = len(result)
|
||||
}
|
||||
result = result[(page-1)*max : lastIndex]
|
||||
ce.Reply("### %s (page %d of %d)\n\n%s", typeName, page, pages, strings.Join(result, "\n"))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue