From 34650131379a4542538da63751a89588d2f2cc85 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Wed, 11 Oct 2023 08:45:18 +0200 Subject: app: fix nil pointer dereference on startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following crash on startup: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x9e2314] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/log.PanicHandler() git.sr.ht/~rjarry/aerc/log/panic-logger.go:51 +0x70f panic({0xae95a0, 0x119f9b0}) runtime/panic.go:890 +0x263 git.sr.ht/~rjarry/aerc/app.(*Aerc).SelectedAccount(0x8503cdd28?) git.sr.ht/~rjarry/aerc/app/aerc.go:384 +0x14 git.sr.ht/~rjarry/aerc/app.SelectedAccount(...) git.sr.ht/~rjarry/aerc/app/app.go:44 git.sr.ht/~rjarry/aerc/app.(*AccountView).isSelected(...) git.sr.ht/~rjarry/aerc/app/account.go:225 git.sr.ht/~rjarry/aerc/app.(*AccountView).UpdateStatus(0x850364380) git.sr.ht/~rjarry/aerc/app/account.go:127 +0x28 git.sr.ht/~rjarry/aerc/app.(*AccountView).SetStatus(0x850364380, {0x850243a50, 0x1, 0x0?}) git.sr.ht/~rjarry/aerc/app/account.go:123 +0x94 git.sr.ht/~rjarry/aerc/app.NewAccountView(0x8503d38c0, 0x85041bf80) git.sr.ht/~rjarry/aerc/app/account.go:111 +0x573 git.sr.ht/~rjarry/aerc/app.NewAerc({0xcab0c0?, 0x11fa3c8}, 0x850433860, 0xbf3040, {0xca75e8?, 0x11ca800}, 0x0?) git.sr.ht/~rjarry/aerc/app/aerc.go:91 +0x6ce git.sr.ht/~rjarry/aerc/app.Init(...) git.sr.ht/~rjarry/aerc/app/app.go:24 main.main() git.sr.ht/~rjarry/aerc/main.go:242 +0x52e There was two things very wrong: - Access of the global aerc pointer before it was initialized. - The host field of AccountView was left there and still accessed but never initialized. Replace the global aerc pointer with a real struct value. Update code accordingly. Remove the AccountView.host field which is now useless. Reported-by: Jens Grassel Reported-by: Matěj Cepl Fixes: bc176bd61ba7 ("app: export global functions") Signed-off-by: Robin Jarry Tested-by: Moritz Poldrack --- app/tabhost.go | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 app/tabhost.go (limited to 'app/tabhost.go') diff --git a/app/tabhost.go b/app/tabhost.go deleted file mode 100644 index 9a206084..00000000 --- a/app/tabhost.go +++ /dev/null @@ -1,15 +0,0 @@ -package app - -import ( - "time" -) - -type TabHost interface { - BeginExCommand(cmd string) - UpdateStatus() - SetError(err string) - PushStatus(text string, expiry time.Duration) *StatusMessage - PushError(text string) *StatusMessage - PushSuccess(text string) *StatusMessage - Beep() -} -- cgit