]> git.lizzy.rs Git - bspwm.git/commitdiff
Fix infinite loop in `find_closest_node`
authorBastien Dejean <nihilhill@gmail.com>
Thu, 6 Jun 2019 09:25:32 +0000 (11:25 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Thu, 6 Jun 2019 09:25:32 +0000 (11:25 +0200)
If `ref->node == NULL` and `ref->desktop->root != NULL` (the reference
desktop contains hidden nodes or/and receptacles), then the ending
condition `n != ref->node` will never be true.

Fixes #977.

src/tree.c

index c57d034919fcc52da793f20b121e3fd4d09e99b0..6b522d143207cc627b643f4a5861b5895383dd3b 100644 (file)
@@ -1626,6 +1626,9 @@ bool find_closest_node(coordinates_t *ref, coordinates_t *dst, cycle_dir_t dir,
                }
                n = (dir == CYCLE_PREV ? prev_leaf(n, d->root) : next_leaf(n, d->root));
                HANDLE_BOUNDARIES(m, d, n);
+               if (ref->node == NULL && d == ref->desktop) {
+                       break;
+               }
        }
 #undef HANDLE_BOUNDARIES
        return false;