From c26d08103b327bd3f2470e542aa55ab354483347 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 25 Feb 2022 00:21:06 +0100 Subject: aerc: always check SelectedAccount return value aerc.SelectedAccount() is used in lots of places. Most of them without checking the return value. In some cases, the currently selected tab is not related to any account (widget.Terminal for example). This can lead to unexpected crashes when accessing account specific configuration. When possible, return an error when no account is currently selected. If no error can be returned, fallback to non-account specific configuration. Signed-off-by: Robin Jarry Reviewed-by: Koni Marti --- commands/msg/unsubscribe.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'commands/msg') diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index 3a69ff98..428e8728 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -89,6 +89,9 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) { func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error { widget := aerc.SelectedTab().(widgets.ProvidesMessage) acct := widget.SelectedAccount() + if acct == nil { + return errors.New("No account selected") + } h := &mail.Header{} h.SetSubject(u.Query().Get("subject")) -- cgit