summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-03 10:28:24 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-03 10:28:24 +1000
commit8289e303085845b26e5fcb953facba36bbb99062 (patch)
tree75384b8790f6497181cdf00a9b26073809b641d6 /sway
parentMerge pull request #2094 from emersion/damage-schedule (diff)
downloadsway-8289e303085845b26e5fcb953facba36bbb99062.tar.gz
sway-8289e303085845b26e5fcb953facba36bbb99062.tar.zst
sway-8289e303085845b26e5fcb953facba36bbb99062.zip
Fix potential crash when destroying workspace
`_container_destroy` emits a destroy event, and any listener for this event should have access to the full container, not a half destroyed one. `_container_destroy` also destroys the swayc, so we have to grab a reference to the sway_workspace so we can free it afterwards. This also fixes a memory leak where the floating container wasn't freed. Fixes #2092.
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/container.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 9e70da09..d0d26631 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -204,9 +204,17 @@ static struct sway_container *container_workspace_destroy(
204 } 204 }
205 } 205 }
206 206
207 free(workspace->sway_workspace); 207 struct sway_workspace *sway_workspace = workspace->sway_workspace;
208
209 // This emits the destroy event and also destroys the swayc.
208 _container_destroy(workspace); 210 _container_destroy(workspace);
209 211
212 // Clean up the floating container
213 sway_workspace->floating->parent = NULL;
214 _container_destroy(sway_workspace->floating);
215
216 free(sway_workspace);
217
210 if (output) { 218 if (output) {
211 output_damage_whole(output->sway_output); 219 output_damage_whole(output->sway_output);
212 } 220 }