aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar David Rosca <nowrep@gmail.com>2021-10-19 07:54:36 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2022-01-07 18:25:13 +0100
commitf92329701b0983ec41fec29d3abc5c751cbe4a28 (patch)
treeb6bfb249e29b08aa17dbc76e0e7ed43bcf21969f
parentswaybar: fix tray item icon scaling, positioning (diff)
downloadsway-f92329701b0983ec41fec29d3abc5c751cbe4a28.tar.gz
sway-f92329701b0983ec41fec29d3abc5c751cbe4a28.tar.zst
sway-f92329701b0983ec41fec29d3abc5c751cbe4a28.zip
container: Fix crash when view unmaps + maps quickly
Followup on 4e4898e90f. If a view quickly maps and unmaps repeatedly, there will be multiple destroyed containers with same view in a single transaction. Each of these containers will then try to destroy this view, resulting in use after free. The container should only destroy the view if the view still belongs to the container. Simple reproducer: couple XMapWindow + XUnmapWindow in a loop followed by XDestroyWindow. See #6605
-rw-r--r--sway/tree/container.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index e5149fb6..79e04ec0 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -80,10 +80,8 @@ void container_destroy(struct sway_container *con) {
80 wlr_texture_destroy(con->marks_urgent); 80 wlr_texture_destroy(con->marks_urgent);
81 wlr_texture_destroy(con->marks_focused_tab_title); 81 wlr_texture_destroy(con->marks_focused_tab_title);
82 82
83 if (con->view) { 83 if (con->view && con->view->container == con) {
84 if (con->view->container == con) { 84 con->view->container = NULL;
85 con->view->container = NULL;
86 }
87 if (con->view->destroying) { 85 if (con->view->destroying) {
88 view_destroy(con->view); 86 view_destroy(con->view);
89 } 87 }