diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-10-04 13:06:55 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-05 21:14:18 +0200 |
commit | d2f4f12f66bc2f632a8a47190fae08ec67c9072e (patch) | |
tree | b9259b18d242111ae79bfef9317d811bc49fd1e6 /widgets | |
parent | d99b6081f7464e332fbad4e79d6004a8a8698e2f (diff) | |
download | aerc-d2f4f12f66bc2f632a8a47190fae08ec67c9072e.tar.gz |
compose: avoid double lock in MouseEvent
The MouseEvent locks the composer, and also calls FocusEditor which
attempts to lock the composer. This results in a deadlock.
No need to call FocusEditor which takes a name as parameter and needs to
iterate over all editors to find the correct one. We already have the
headerEditor object, use it directly.
Fixes: bf2bf8c242cb ("compose: prevent out of bounds access")
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/compose.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index ee07d1cd..eca76842 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -618,10 +618,13 @@ func (c *Composer) MouseEvent(localX int, localY int, event tcell.Event) { c.Lock() defer c.Unlock() c.grid.MouseEvent(localX, localY, event) - for _, e := range c.focusable { + for i, e := range c.focusable { he, ok := e.(*headerEditor) if ok && he.focused { - c.FocusEditor(he.name) + c.focusable[c.focused].Focus(false) + c.focused = i + c.focusable[c.focused].Focus(true) + return } } } |