aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-09 22:44:03 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-09 22:45:39 +0100
commit5ae7a23e1ec99f1e552967ed9d058133b6c860c6 (patch)
treef18d208214fb4ac827e8e20124a3cd2b103ea340
parent1e5069cdd3e8d59c8c942b0835a459e0ae4e8334 (diff)
downloadaerc-5ae7a23e1ec99f1e552967ed9d058133b6c860c6.tar.gz
account: fix crash/race on init
When an account is initialized too quickly, setTitle may be called before acct.tab is initialized, leading to a crash: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: panic({0xa49820, 0x1059510}) runtime/panic.go:890 +0x262 git.sr.ht/~rjarry/aerc/lib/ui.(*Tab).SetTitle(...) git.sr.ht/~rjarry/aerc/lib/ui/tab.go:37 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).setTitle(0xc000838000) git.sr.ht/~rjarry/aerc/widgets/account.go:617 +0x2a0 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).onMessage(0xc000838000, {0xbffc60?, 0xc0000f1080?}) git.sr.ht/~rjarry/aerc/widgets/account.go:364 +0x13e8 git.sr.ht/~rjarry/aerc/widgets.(*Aerc).HandleMessage(0xc0000f4000, {0xbffc60, 0xc0000f1080}) git.sr.ht/~rjarry/aerc/widgets/aerc.go:174 +0x5f main.main() git.sr.ht/~rjarry/aerc/aerc.go:252 +0x965 Avoid this. Fixes: 6b39c0dae1e1 ("tabs: use template for account tab name") Signed-off-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--widgets/account.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 5b5d4dcd..fdd33301 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -604,6 +604,9 @@ func (acct *AccountView) Vsplit(n int) error {
func (acct *AccountView) setTitle() {
var data state.TemplateData
+ if acct.tab == nil {
+ return
+ }
data.SetAccount(acct.acct)
data.SetFolder(acct.SelectedDirectory())
data.SetRUE(acct.dirlist.List(), acct.dirlist.GetRUECount)