notify: don't close FD 0

This fixes a regression where closing a terminal instance, or hard- or
soft-resetting a terminal caused FD 0 to be closed.

This meant it became re-usable. Usually, by memfd_create() when
allocating a new surface buffer. So far nothing _really_ bad has
happened.

But what if FD 0 is now used by a memfd, and we close _another_
terminal instance?

This causes our memfd to be closed. And then, when e.g. trying to
scroll the terminal content: fallocate() fails with bad FD.
This commit is contained in:
Daniel Eklöf 2024-07-30 16:33:19 +02:00
parent a3ad740251
commit 0a5ba708e4
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 11 additions and 4 deletions

View file

@ -505,10 +505,13 @@ notify_icon_del(struct terminal *term, const char *id)
void
notify_icon_free(struct notification_icon *icon)
{
if (icon->tmp_file_fd >= 0)
close(icon->tmp_file_fd);
if (icon->tmp_file_name != NULL)
if (icon->tmp_file_name != NULL) {
unlink(icon->tmp_file_name);
if (icon->tmp_file_fd >= 0) {
xassert(icon->tmp_file_fd > 0); // DEBUG
close(icon->tmp_file_fd);
}
}
free(icon->id);
free(icon->symbolic_name);