4782473064fa0a712aa1e26333ad175446404a64 — Koni Marti 10 months ago 71eda7d
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>
1 files changed, 3 insertions(+), 0 deletions(-)

M widgets/terminal.go
M widgets/terminal.go => widgets/terminal.go +3 -0
@@ 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 {
		n, err := term.vterm.Read(buf)
		if err != nil {