aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-07-05 15:36:29 -0500
committerRobin Jarry <robin@jarry.cc>2022-07-10 20:40:22 +0200
commit635530b12d46ff29555ba322a6bfd3c5bf8f4e7a (patch)
tree287fe4df58ded4d63c47ae3dd293e30c54660ab5 /widgets
parente19b411e5209bab209fa8d0ee11a0880175ea0e6 (diff)
downloadaerc-635530b12d46ff29555ba322a6bfd3c5bf8f4e7a.tar.gz
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>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msglist.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index ec14e794..399ed724 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -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) {