aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/terminal.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-01-11 12:02:28 +0100
committerRobin Jarry <robin@jarry.cc>2022-01-14 20:35:07 +0100
commit4782473064fa0a712aa1e26333ad175446404a64 (patch)
treeed81b8699bd4d588034a58595ed4c7641a797464 /widgets/terminal.go
parent71eda7d37c8ef38502c360b518fcbf5960497eea (diff)
downloadaerc-4782473064fa0a712aa1e26333ad175446404a64.tar.gz
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>
Diffstat (limited to 'widgets/terminal.go')
-rw-r--r--widgets/terminal.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 2a1afa5f..68c95534 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -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