render: tiocswinsz: don’t remove/close the fd passed as argument

There’s a chance the resize timeout FD was closed, and *reused*, after
epoll() told us the FD is readable, but before our callback runs.

Thus, closing the FD provided as an argument is dangerous, as it may
refer to something completely different.
This commit is contained in:
Daniel Eklöf 2021-07-14 20:14:10 +02:00
parent 0c777d825d
commit 9658e9cc18
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -3119,8 +3119,10 @@ fdm_tiocswinsz(struct fdm *fdm, int fd, int events, void *data)
if (events & EPOLLIN)
tiocswinsz(term);
fdm_del(fdm, fd);
term->window->resize_timeout_fd = -1;
if (term->window->resize_timeout_fd >= 0) {
fdm_del(fdm, term->window->resize_timeout_fd);
term->window->resize_timeout_fd = -1;
}
return true;
}