commit a2e5856f22739a9056fa41789369948450cd7e36
Author:     Hiltjo Posthuma <[email protected]>
AuthorDate: Sat Jun 25 10:11:26 2022 +0200
Commit:     Hiltjo Posthuma <[email protected]>
CommitDate: Sat Jun 25 10:11:26 2022 +0200

    fix segfault after querying window with no children
    
    Reported by Augusto Castelo <[email protected]>, thanks!

diff --git a/lsw.c b/lsw.c
index fc40fef..8b04ef2 100644
--- a/lsw.c
+++ b/lsw.c
@@ -36,7 +36,7 @@ lsw(Window win) {
        Window *wins, *w, dw;
        XWindowAttributes wa;
 
-       if(!XQueryTree(dpy, win, &dw, &dw, &wins, &n))
+       if(!XQueryTree(dpy, win, &dw, &dw, &wins, &n) || !n)
                return;
        for(w = &wins[n-1]; w >= &wins[0]; w--)
                if(XGetWindowAttributes(dpy, *w, &wa)

Reply via email to