aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2021-01-05 12:51:31 +0100
committerSimon Ser <contact@emersion.fr>2021-01-05 13:53:58 +0100
commit0cba1ce7478035fb90ca2043868f4be78ff165a1 (patch)
treed8829260f71c7b8da2ef8da5a53707a0be450686
parentbf926e31a0bda9f621eb25ffe77046d171e48b13 (diff)
gtk primary selection: destroy devices before manager
Since device_destroy() calls wl_list_remove() on the device's link, the manager must still be valid. However if the manager is destroyed before the seat as the wl_display destroy handlers are called, devices listening for the seat to be destroyed will access free'd memory in wl_list_remove().
-rw-r--r--types/wlr_gtk_primary_selection.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/types/wlr_gtk_primary_selection.c b/types/wlr_gtk_primary_selection.c
index 0bf4c70f..6ee877e4 100644
--- a/types/wlr_gtk_primary_selection.c
+++ b/types/wlr_gtk_primary_selection.c
@@ -452,6 +452,12 @@ static void primary_selection_device_manager_bind(struct wl_client *client,
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_gtk_primary_selection_device_manager *manager =
wl_container_of(listener, manager, display_destroy);
+
+ struct wlr_gtk_primary_selection_device *device, *tmp;
+ wl_list_for_each_safe(device, tmp, &manager->devices, link) {
+ device_destroy(device);
+ }
+
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);