~sircmpwn/aerc

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Fix crash when no message is selected

Details
Message ID
<20191128182045.9311-1-wiktor@metacode.biz>
DKIM signature
missing
Download raw message
Patch: +4 -1
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(-)

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)
-- 
2.24.0
Details
Message ID
<BYWPRBI05Q0A.261UBS7OAM2HO@homura>
In-Reply-To
<20191128182045.9311-1-wiktor@metacode.biz> (view parent)
DKIM signature
missing
Download raw message
Thanks!

To git.sr.ht:~sircmpwn/aerc
   31e3e9f..abd9e78  master -> master
Reply to thread Export thread (mbox)