diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2018-04-13 14:57:36 +0900 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-04-13 14:58:23 +0900 |
commit | de65d05821d5eaae6525e86363c76aaa395346fb (patch) | |
tree | 0e8d5cc6ab66aa06b9387b2afb40d5e304c82062 | |
parent | seat_set_focus_wrap: fix use-after-free when destroying last focused container (diff) | |
download | sway-de65d05821d5eaae6525e86363c76aaa395346fb.tar.gz sway-de65d05821d5eaae6525e86363c76aaa395346fb.tar.zst sway-de65d05821d5eaae6525e86363c76aaa395346fb.zip |
container_destroy: fix segfault
cont->children doesn't have to be NULL when there is no children
-rw-r--r-- | sway/tree/container.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index ea1c93bb..c0067493 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -104,7 +104,7 @@ static void _container_destroy(struct sway_container *cont) { | |||
104 | if (cont->children != NULL && cont->children->length) { | 104 | if (cont->children != NULL && cont->children->length) { |
105 | // remove children until there are no more, container_destroy calls | 105 | // remove children until there are no more, container_destroy calls |
106 | // container_remove_child, which removes child from this container | 106 | // container_remove_child, which removes child from this container |
107 | while (cont->children != NULL) { | 107 | while (cont->children != NULL && cont->children->length > 0) { |
108 | struct sway_container *child = cont->children->items[0]; | 108 | struct sway_container *child = cont->children->items[0]; |
109 | container_remove_child(child); | 109 | container_remove_child(child); |
110 | _container_destroy(child); | 110 | _container_destroy(child); |