aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-07-11 07:54:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-07-11 07:59:17 +0000
commit0a6e7e6167e04e1ee38cfaba4d38c2776cf474b4 (patch)
tree4f93f952cbc5a4a4f02af37b53b398da6d86a5ce
parentMerge branch 'man-page-typo' (diff)
url-mode: purge SHM pixmaps when destroying URLs
Unlike other surface types, the SHM cookie depends on the address of each URL instance. This means if we enable, disable, and then enable URL mode again (thus showing exactly the same URLs as the first time), the URLs will have new addresses, and thus the old SHM pixmaps will not get purged automatically. So, manually purge them when destroying the URLs.
-rw-r--r--CHANGELOG.md2
-rw-r--r--url-mode.c3
-rw-r--r--wayland.c5
3 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index db325da7..44093dc5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,8 @@
`tweak.allow-overflowing-double-width-glyphs`.
* Regression: crash when a single-char, double-width glyph is in the
last column, and `tweak.allow-overflowing-double-width-glyphs=yes`.
+* FD exhaustion when repeatedly entering/exiting URL mode with many
+ URLs.
### Security
diff --git a/url-mode.c b/url-mode.c
index 5f56a2f6..8ac5631e 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -14,6 +14,7 @@
#include "grid.h"
#include "render.h"
#include "selection.h"
+#include "shm.h"
#include "spawn.h"
#include "terminal.h"
#include "uri.h"
@@ -728,7 +729,9 @@ urls_reset(struct terminal *term)
if (term->window != NULL) {
tll_foreach(term->window->urls, it) {
+ const struct url *url = it->item.url;
wayl_win_subsurface_destroy(&it->item.surf);
+ shm_purge(term->wl->shm, shm_cookie_url(url));
tll_remove(term->window->urls, it);
}
}
diff --git a/wayland.c b/wayland.c
index 80fef88a..ecc4f31e 100644
--- a/wayland.c
+++ b/wayland.c
@@ -26,6 +26,7 @@
#include "input.h"
#include "render.h"
#include "selection.h"
+#include "shm.h"
#include "util.h"
#include "xmalloc.h"
@@ -1410,6 +1411,9 @@ wayl_win_destroy(struct wl_window *win)
if (win == NULL)
return;
+ struct terminal *term = win->term;
+ struct wl_shm *shm = term->wl->shm;
+
if (win->csd.move_timeout_fd != -1)
close(win->csd.move_timeout_fd);
@@ -1457,6 +1461,7 @@ wayl_win_destroy(struct wl_window *win)
tll_foreach(win->urls, it) {
wayl_win_subsurface_destroy(&it->item.surf);
+ shm_purge(shm, shm_cookie_url(it->item.url));
tll_remove(win->urls, it);
}