mirror of
https://github.com/swaywm/sway
synced 2024-11-18 14:53:52 +01:00
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
This commit is contained in:
parent
f8d0e1f946
commit
3c93e2cf1b
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user