fix segfault when copy-pasting into compose editor
fixes the segmentation fault when copy-pasting a large text into the composer editor. The problem is a concurrent read of the vterm field in the Terminal widget in its flushTerminal() method which can be avoided with a mutex. Fixes: https://todo.sr.ht/~rjarry/aerc/12 Signed-off-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
parent
71eda7d37c
commit
4782473064
1 changed files with 3 additions and 0 deletions
|
@ -106,6 +106,7 @@ type Terminal struct {
|
|||
damage []vterm.Rect // protected by damageMutex
|
||||
damageMutex sync.Mutex
|
||||
writeMutex sync.Mutex
|
||||
readMutex sync.Mutex
|
||||
|
||||
OnClose func(err error)
|
||||
OnEvent func(event tcell.Event) bool
|
||||
|
@ -155,7 +156,9 @@ func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
|
|||
func (term *Terminal) flushTerminal() {
|
||||
buf := make([]byte, 4096)
|
||||
for {
|
||||
term.readMutex.Lock()
|
||||
n, err := term.vterm.Read(buf)
|
||||
term.readMutex.Unlock()
|
||||
if err != nil {
|
||||
term.Close(err)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue