richardgv / skippy-xd

A full-screen Exposé-style standalone task switcher for X11.
GNU General Public License v2.0
341 stars 78 forks source link

SIGSEGV when activating on empty desktop #39

Closed arkq closed 10 years ago

arkq commented 10 years ago

When activating skippy on an empty desktop with no faked root window (e.g. fluxbox), uninitialized pointer is freed.

It is caused by the fact that XGetInputFocus returns PointerRoot in this case, which is not checked. Passing this value as a window ID causes X* functions to fail. In the final results uninitialized pointer is freed (wm.c function wm_get_focused line XFree(children)).

Proposed patch:

Bug fix: Proper handling of the PointerRoot focus

Fix a SIGSEGV issue when input focus is on the X root window. In that case,
XGetInputFocus returns PointerRoot, which can not be passed as a valid
window ID.

Signed-off-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>

---
 src/wm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/wm.c b/src/wm.c
index bebf44c..91b7c06 100644
--- a/src/wm.c
+++ b/src/wm.c
@@ -626,8 +626,8 @@ wm_get_focused(Display *dpy)
    unsigned char *data;

    XGetInputFocus(dpy, &focused, &revert_to);
-   
-   while(focused != None && focused != root)
+
+   while(focused != None && focused != PointerRoot && focused != root)
    {
        status = XGetWindowProperty(dpy, focused, XA_WM_STATE,
                                    0L, 1L, False, XA_WM_STATE, &real_type, &real_format,
--
1.8.3.2
richardgv commented 10 years ago

Thanks for the report and the patch, Arkq! Although I'm not able to let XGetInputFocus() return PointerRoot under Flubox somehow, I rewrote wm_get_focused() to fix all the little issues inside. (58b752f) Does it work for you right now?

arkq commented 10 years ago

Yes, right now everything works just fine. Thanks.