msglist: fix panic for index-out-of-range
I didn't save the stack trace, but msglist.Selected() can create a panic for index out of range due to the math operations in the map. My stack trace resulted in a [-9]. This patch reuses the msgstore.Selected() method, which already has bounds checking. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
e19b411e52
commit
635530b12d
|
@ -403,9 +403,7 @@ func (ml *MessageList) Empty() bool {
|
|||
}
|
||||
|
||||
func (ml *MessageList) Selected() *models.MessageInfo {
|
||||
store := ml.Store()
|
||||
uids := store.Uids()
|
||||
return store.Messages[uids[len(uids)-ml.store.SelectedIndex()-1]]
|
||||
return ml.Store().Selected()
|
||||
}
|
||||
|
||||
func (ml *MessageList) Select(index int) {
|
||||
|
|
Loading…
Reference in New Issue