From 3cd0d5bc284985703a3eb1c2eae3c14a28f7200b Mon Sep 17 00:00:00 2001 From: Tom Lebreux Date: Mon, 8 Apr 2019 23:14:14 -0400 Subject: Fix segfault on :view-message for unloaded message This also fixes segfault on :view-message on empty directory Signed-off-by: Tom Lebreux --- commands/account/view-message.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'commands/account/view-message.go') diff --git a/commands/account/view-message.go b/commands/account/view-message.go index edafd09b..ea6addc2 100644 --- a/commands/account/view-message.go +++ b/commands/account/view-message.go @@ -17,8 +17,14 @@ func ViewMessage(aerc *widgets.Aerc, args []string) error { return errors.New("Usage: view-message") } acct := aerc.SelectedAccount() + if acct.Messages().Empty() { + return nil + } store := acct.Messages().Store() msg := acct.Messages().Selected() + if msg == nil { + return nil + } viewer := widgets.NewMessageViewer(aerc.Config(), store, msg) aerc.NewTab(viewer, runewidth.Truncate( msg.Envelope.Subject, 32, "…")) -- cgit