From 8ffcd3e5adfa008f33989d4589a47ae1cd1a5e68 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Mon, 17 Oct 2022 09:38:05 +0200 Subject: [PATCH] switch-account: fix out-of-bounds panic Fix out-of-bounds panic by updating the focused int variable when headers change in the switch-account commands. Fixes: d371c1ac8 ("commands: add switch-account command for composer") Reported-by: Bence Ferdinandy Signed-off-by: Koni Marti Acked-by: Robin Jarry --- widgets/compose.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/widgets/compose.go b/widgets/compose.go index ae3bca1..dc0c21a 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -176,6 +176,9 @@ func (c *Composer) setupFor(acct *AccountView) error { if focusEditor != nil { c.focusable = append(c.focusable, focusEditor) } + if c.focused >= len(c.focusable) { + c.focused = len(c.focusable) - 1 + } // redraw the grid c.updateGrid()