diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-08-06 12:04:16 +0200 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-08-06 16:56:39 +0200 |
commit | 3c93e2cf1bf56f4bdbe128eebf1fb250ab136ed2 (patch) | |
tree | bfae22df29dd5cf78c60e35626056fa740f47ae0 /sway | |
parent | Merge pull request #1300 from emersion/patch-1 (diff) | |
download | sway-3c93e2cf1bf56f4bdbe128eebf1fb250ab136ed2.tar.gz sway-3c93e2cf1bf56f4bdbe128eebf1fb250ab136ed2.tar.zst sway-3c93e2cf1bf56f4bdbe128eebf1fb250ab136ed2.zip |
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')
-rw-r--r-- | sway/container.c | 2 |
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) { | |||
849 | 849 | ||
850 | void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) { | 850 | void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) { |
851 | if (container) { | 851 | if (container) { |
852 | f(container, data); | ||
853 | int i; | 852 | int i; |
854 | if (container->children) { | 853 | if (container->children) { |
855 | for (i = 0; i < container->children->length; ++i) { | 854 | 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 | |||
863 | container_map(child, f, data); | 862 | container_map(child, f, data); |
864 | } | 863 | } |
865 | } | 864 | } |
865 | f(container, data); | ||
866 | } | 866 | } |
867 | } | 867 | } |
868 | 868 | ||