summaryrefslogtreecommitdiff
path: root/commands/compose/postpone.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-02-25 00:21:06 +0100
committerRobin Jarry <robin@jarry.cc>2022-02-25 13:56:53 +0100
commitc26d08103b327bd3f2470e542aa55ab354483347 (patch)
tree4c0567246916d676b71a4675c76a93a198add65f /commands/compose/postpone.go
parent91ead11c47252ca8998fdad7b0770d6b8d07c987 (diff)
downloadaerc-c26d08103b327bd3f2470e542aa55ab354483347.zip
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 <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'commands/compose/postpone.go')
-rw-r--r--commands/compose/postpone.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index f918b52..9462a9c 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -31,6 +31,10 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: postpone")
}
+ acct := aerc.SelectedAccount()
+ if acct == nil {
+ return errors.New("No account selected")
+ }
composer, _ := aerc.SelectedTab().(*widgets.Composer)
config := composer.Config()
tabName := aerc.TabNames()[aerc.SelectedTabIndex()]
@@ -48,7 +52,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
header.SetContentType("text/plain", map[string]string{"charset": "UTF-8"})
header.Set("Content-Transfer-Encoding", "quoted-printable")
worker := composer.Worker()
- dirs := aerc.SelectedAccount().Directories().List()
+ dirs := acct.Directories().List()
alreadyCreated := false
for _, dir := range dirs {
if dir == config.Postpone {