JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix crash on apps that dont play nice with NET_WM_PID.
authorMarco Peereboom <marco@conformal.com>
Thu, 23 Jun 2011 11:37:16 +0000 (11:37 +0000)
committerMarco Peereboom <marco@conformal.com>
Thu, 23 Jun 2011 11:37:16 +0000 (11:37 +0000)
scrotwm.c

index 2d10ceb..499ee6d 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -1063,6 +1063,9 @@ find_pid(long pid)
 
        DNPRINTF(SWM_D_MISC, "find_pid: %lu\n", pid);
 
+       if (pid == 0)
+               return (NULL);
+
        TAILQ_FOREACH(p, &pidlist, entry) {
                if (p->pid == pid)
                        return (p);
@@ -4761,7 +4764,7 @@ window_get_pid(Window win)
        int                     actual_format_return = 0;
        unsigned long           nitems_return = 0;
        unsigned long           bytes_after_return = 0;
-       long                    *pid = 0;
+       long                    *pid = NULL;
        long                    ret = 0;
 
        if (XGetWindowProperty(display, win,
@@ -4770,8 +4773,12 @@ window_get_pid(Window win)
            &nitems_return, &bytes_after_return,
            (unsigned char**)(void*)&pid) != Success)
                return (0);
+       if (actual_type_return != XA_CARDINAL)
+               return (0);
+       if (pid == NULL)
+               return (0);
 
-       ret = pid[0];
+       ret = *pid;
        XFree(pid);
 
        return (ret);