X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=scrotwm.c;h=499ee6dacd0f9a09bd3e2182adb1c0da456b9121;hb=948314b98e7b6eccd9e2b99294190101b043c909;hp=2d10ceb0ccfc717807c3fe5d655659a777f85c37;hpb=5f8a010ab295ed72a1f432a3c47fe804dc87e76d;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 2d10ceb..499ee6d 100644 --- 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);