terminal: fix nil pointer dereference in pty.Getsize
pty.Getsize() is used in the Draw function of the terminal widget and wraps the pty.GetsizeFull() function. However, pty.Getsize does not check the returned error from pty.GetsizeFull before dereferencing the winsize struct. In case of an error, this will cause a nil pointer deference and panic. This has been reported in the upstream package, but in the meantime, we can directly use pty.GetsizeFull. References: https://todo.sr.ht/~rjarry/aerc/11 Signed-off-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
parent
22ad9e199a
commit
7f34cab5e5
|
@ -254,10 +254,13 @@ func (term *Terminal) Draw(ctx *ui.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, cols, err := pty.Getsize(term.pty)
|
ws, err := pty.GetsizeFull(term.pty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
rows := int(ws.Rows)
|
||||||
|
cols := int(ws.Cols)
|
||||||
|
|
||||||
if ctx.Width() != cols || ctx.Height() != rows {
|
if ctx.Width() != cols || ctx.Height() != rows {
|
||||||
term.writeMutex.Lock()
|
term.writeMutex.Lock()
|
||||||
pty.Setsize(term.pty, &winsize)
|
pty.Setsize(term.pty, &winsize)
|
||||||
|
|
Loading…
Reference in New Issue