diff options
author | Wiktor Kwapisiewicz <wiktor@metacode.biz> | 2019-11-28 19:20:45 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-12-04 09:45:07 -0500 |
commit | abd9e78f024580d476cb299a575a7aa54c53a4b4 (patch) | |
tree | 932b3d04383dcff7764bdcdbc2980abe68d9ab0a /commands/account/view.go | |
parent | 31e3e9f56e0b8123f0238537112496b407055aef (diff) | |
download | aerc-abd9e78f024580d476cb299a575a7aa54c53a4b4.tar.gz |
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.
Diffstat (limited to 'commands/account/view.go')
-rw-r--r-- | commands/account/view.go | 5 |
1 files changed, 4 insertions, 1 deletions
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) |