aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 41212a717e9012179e4333a68efdf52f3f3dadab
parent 8a42dfc87c61a393983ad6da895e74056f9b2fac
Author: Tom Lebreux <tomlebreux@cock.li>
Date:   Fri,  5 Apr 2019 15:03:18 -0400

Fix infinite loop on empty DirectoryContents

When changing to an empty directory, ml.selected is 0, and the length
of ml.store.Uids is 0. The loop condition is always true so we have
an infinite loop causing 100% CPU usage and prevents us to change to
other directories.

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>

Diffstat:
Mwidgets/msglist.go | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/widgets/msglist.go b/widgets/msglist.go @@ -111,8 +111,10 @@ func (ml *MessageList) storeUpdate(store *lib.MessageStore) { if ml.store != store { return } - for ml.selected >= len(ml.store.Uids) { - ml.Prev() + if len(ml.store.Uids) > 0 { + for ml.selected >= len(ml.store.Uids) { + ml.Prev() + } } ml.Invalidate() }