about summary refs log tree commit diff stats
path: root/commands/account
diff options
context:
space:
mode:
authorTom Lebreux <tomlebreux@cock.li>2019-04-08 23:14:14 -0400
committerDrew DeVault <sir@cmpwn.com>2019-04-10 15:40:06 -0400
commit3cd0d5bc284985703a3eb1c2eae3c14a28f7200b (patch)
tree8e782ccd35319576ec108dbcd755abbfba106c11 /commands/account
parentec09ec8b0e70dabe216c2109e52fd21ef7fcae2b (diff)
downloadaerc-3cd0d5bc284985703a3eb1c2eae3c14a28f7200b.tar.gz
Fix segfault on :view-message for unloaded message
This also fixes segfault on :view-message on empty directory

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
Diffstat (limited to 'commands/account')
-rw-r--r--commands/account/view-message.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/commands/account/view-message.go b/commands/account/view-message.go
index edafd09..ea6addc 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, "…"))