summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2024-02-28 16:48:47 +0100
committersfan5 <sfan5@live.de>2024-02-29 17:24:05 +0100
commitf36ab2c60963ff5244c16c459c40b6f58d04c8ef (patch)
treef55fc9fe80433e3f839559a2474136300a84701c
parent15c48f3dc122be4b29701355cc48eb63cf8e3029 (diff)
downloadmpv-f36ab2c60963ff5244c16c459c40b6f58d04c8ef.tar.bz2
mpv-f36ab2c60963ff5244c16c459c40b6f58d04c8ef.tar.xz
wayland_common: free DND resources on shutdown and error
This leaked only in edge cases, if at all.
-rw-r--r--video/out/wayland_common.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index cd37c56e83..f45f808773 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1549,6 +1549,15 @@ static const struct wl_registry_listener registry_listener = {
};
/* Static functions */
+static void free_dnd_data(struct vo_wayland_state *wl)
+{
+ // caller should close wl->dnd_fd if appropriate
+
+ wl->dnd_action = -1;
+ TA_FREEP(&wl->dnd_mime_type);
+ wl->dnd_mime_score = 0;
+}
+
static void check_dnd_fd(struct vo_wayland_state *wl)
{
if (wl->dnd_fd == -1)
@@ -1573,21 +1582,18 @@ static void check_dnd_fd(struct vo_wayland_state *wl)
MP_VERBOSE(wl, "Read %zu bytes from the DND fd\n", file_list.len);
+ if (wl->dnd_offer)
+ wl_data_offer_finish(wl->dnd_offer);
+
mp_event_drop_mime_data(wl->vo->input_ctx, wl->dnd_mime_type,
file_list, wl->dnd_action);
- talloc_free(file_list.start);
- if (wl->dnd_mime_type)
- talloc_free(wl->dnd_mime_type);
-
- if (wl->dnd_action >= 0 && wl->dnd_offer)
- wl_data_offer_finish(wl->dnd_offer);
- wl->dnd_action = -1;
- wl->dnd_mime_type = NULL;
- wl->dnd_mime_score = 0;
+ talloc_free(file_list.start);
+ free_dnd_data(wl);
}
if (fdp.revents & (POLLIN | POLLERR | POLLHUP)) {
+ free_dnd_data(wl);
close(wl->dnd_fd);
wl->dnd_fd = -1;
}
@@ -2593,6 +2599,10 @@ void vo_wayland_uninit(struct vo *vo)
if (!wl)
return;
+ if (wl->dnd_fd != -1)
+ close(wl->dnd_fd);
+ free_dnd_data(wl);
+
mp_input_put_key(wl->vo->input_ctx, MP_INPUT_RELEASE_ALL);
if (wl->compositor)