diff options
author | Robin Jarry <robin@jarry.cc> | 2023-07-31 14:00:44 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-07-31 15:05:11 +0200 |
commit | dc5c35758dca410350ff36f9bf5c9090236e6043 (patch) | |
tree | 8ed652223532fa9aa4d2b80f63b296f9d052f5c9 /widgets | |
parent | 037ee1a6cfb35383f34b0fcc70dfc53f9463bd09 (diff) | |
download | aerc-dc5c35758dca410350ff36f9bf5c9090236e6043.tar.gz |
compose: fix panic when adding empty header with uppercase letters
Running `:header Hello` causes a panic:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa09328]
goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/widgets.(*Composer).AddEditor
git.sr.ht/~rjarry/aerc/widgets/compose.go:1302
git.sr.ht/~rjarry/aerc/commands/compose.Header.Execute
git.sr.ht/~rjarry/aerc/commands/compose/header.go:83
git.sr.ht/~rjarry/aerc/commands.(*Commands).ExecuteCommand
git.sr.ht/~rjarry/aerc/commands/commands.go:133
main.execCommand
git.sr.ht/~rjarry/aerc/main.go:71
This is because addEditor() converts the header name to lowercase before
updating the c.editors map. After this, c.editors[header] (with `header`
containing uppercase letters) returns nil causes a nil pointer access.
This is a side effect of splitting AddEditor into public and private
functions.
focusEditor also converts the argument to lowercase. Fix and simplify
this. Only call focusEditor with whatever the user provided.
Fixes: 11e5390fa0ac ("compose: implement embedded headers in editor")
Reported-by: Koni Marti <koni.marti@gmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/compose.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index c0f4af4f..fa88b0f0 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -1299,7 +1299,7 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) err } value = c.addEditor(header, value, appendHeader) if value == "" { - c.focusEditor(c.editors[header].name) + c.focusEditor(header) } c.updateGrid() return nil |