From abd9e78f024580d476cb299a575a7aa54c53a4b4 Mon Sep 17 00:00:00 2001 From: Wiktor Kwapisiewicz Date: Thu, 28 Nov 2019 19:20:45 +0100 Subject: Fix crash when no message is selected Pressing `Enter` on a view that has not yet loaded messages (e.g. at startup) would return `nil` from `Selected()`. Accessing `msg.Uid` on a `nil` reference crashes aerc. This patch moves the `msg == nil` check before accessing `msg.Uid` thus avoiding the crash. To test this patch repeatedly press `Enter` on startup. --- commands/account/view.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'commands/account') diff --git a/commands/account/view.go b/commands/account/view.go index b287406..aab9052 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -30,8 +30,11 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error { } store := acct.Messages().Store() msg := acct.Messages().Selected() + if msg == nil { + return nil + } _, deleted := store.Deleted[msg.Uid] - if msg == nil || deleted { + if deleted { return nil } viewer := widgets.NewMessageViewer(acct, aerc.Config(), store, msg) -- cgit 1.4.1-2-gfad0