aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTadeo Kondrak <me@tadeo.ca>2021-02-07 21:42:52 -0700
committerSimon Ser <contact@emersion.fr>2021-02-08 18:09:00 +0100
commit99ef23b62c49572d2654a6ff7d913530bd97579e (patch)
treeefb26bdf44af4618127549381790a41ea71861aa
parentd595a4ebe3d432cdd3f551d6d067b341d0afdc19 (diff)
xdg-foreign: Make imported object inert when exported is destroyed
Fixes a double-free experienced with Firefox and xdg-desktop-portal-gtk.
-rw-r--r--types/wlr_xdg_foreign_v1.c3
-rw-r--r--types/wlr_xdg_foreign_v2.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/types/wlr_xdg_foreign_v1.c b/types/wlr_xdg_foreign_v1.c
index 2ed125af..cd07b6f5 100644
--- a/types/wlr_xdg_foreign_v1.c
+++ b/types/wlr_xdg_foreign_v1.c
@@ -159,6 +159,7 @@ static void finish_imported(struct wlr_xdg_imported_v1 *imported) {
wl_list_remove(&imported->link);
wl_list_init(&imported->link);
+ wl_resource_set_user_data(imported->resource, NULL);
free(imported);
}
@@ -167,6 +168,7 @@ static void finish_exported(struct wlr_xdg_exported_v1 *exported) {
wl_list_remove(&exported->xdg_surface_destroy.link);
wl_list_remove(&exported->link);
+ wl_resource_set_user_data(exported->resource, NULL);
free(exported);
}
@@ -185,7 +187,6 @@ static void handle_xdg_surface_destroy(
struct wlr_xdg_exported_v1 *exported =
wl_container_of(listener, exported, xdg_surface_destroy);
- wl_resource_set_user_data(exported->resource, NULL);
finish_exported(exported);
}
diff --git a/types/wlr_xdg_foreign_v2.c b/types/wlr_xdg_foreign_v2.c
index e1b078c1..3ef74a94 100644
--- a/types/wlr_xdg_foreign_v2.c
+++ b/types/wlr_xdg_foreign_v2.c
@@ -159,6 +159,7 @@ static void finish_imported(struct wlr_xdg_imported_v2 *imported) {
wl_list_remove(&imported->link);
wl_list_init(&imported->link);
+ wl_resource_set_user_data(imported->resource, NULL);
free(imported);
}
@@ -167,6 +168,7 @@ static void finish_exported(struct wlr_xdg_exported_v2 *exported) {
wl_list_remove(&exported->xdg_surface_destroy.link);
wl_list_remove(&exported->link);
+ wl_resource_set_user_data(exported->resource, NULL);
free(exported);
}
@@ -185,7 +187,6 @@ static void handle_xdg_surface_destroy(
struct wlr_xdg_exported_v2 *exported =
wl_container_of(listener, exported, xdg_surface_destroy);
- wl_resource_set_user_data(exported->resource, NULL);
finish_exported(exported);
}