aboutsummaryrefslogtreecommitdiff
path: root/sway/container.c
diff options
context:
space:
mode:
authorCalvin Lee <cyrus296@gmail.com>2017-08-06 12:04:16 +0200
committerCalvin Lee <cyrus296@gmail.com>2017-08-06 16:56:39 +0200
commit3c93e2cf1bf56f4bdbe128eebf1fb250ab136ed2 (patch)
treebfae22df29dd5cf78c60e35626056fa740f47ae0 /sway/container.c
parentf8d0e1f94635e6334d2d646797dfd43c219e213a (diff)
Prevent race condition in the kill command
When killing views with `close_views` a use-after-free can sometimes occur because parent views are killed before their children. This commit makes `container_map` run functions on child containers before their parent, fixing the race. Fixes #1302
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sway/container.c b/sway/container.c
index 125e1e3d..14647b3a 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -849,7 +849,6 @@ int swayc_gap(swayc_t *container) {
void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) {
if (container) {
- f(container, data);
int i;
if (container->children) {
for (i = 0; i < container->children->length; ++i) {
@@ -863,6 +862,7 @@ void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), voi
container_map(child, f, data);
}
}
+ f(container, data);
}
}