Index: src/manage.c =================================================================== RCS file: /sources/ratpoison/ratpoison/src/manage.c,v retrieving revision 1.103 diff -u -r1.103 manage.c --- src/manage.c 19 May 2007 12:34:58 -0000 1.103 +++ src/manage.c 4 Jul 2007 20:13:05 -0000 @@ -198,26 +198,27 @@ static char * get_wmname (Window w) { - unsigned char *name = NULL; + char *name = NULL; char *ret; XTextProperty text_prop; - int n; + int status, n; char** cl; if (XGetWMName(dpy, w, &text_prop) != 0) { - if (text_prop.encoding == XA_STRING) { - name = (char *)text_prop.value; + status = XmbTextPropertyToTextList(dpy, &text_prop, &cl, &n); + if (status == Success && cl && n > 0) { + name = strdup(cl[0]); + XFreeStringList(cl); } else { - XmbTextPropertyToTextList(dpy, &text_prop, &cl, &n); - XFree (text_prop.value); - if (cl) { - name = strdup(cl[0]); - XFreeStringList(cl); + if (text_prop.encoding == XA_STRING) { + name = strdup((const char*)text_prop.value); } else { - PRINT_DEBUG (("I can't get the WMName.\n")); - return NULL; + PRINT_DEBUG (("I can't get the WMName.\n")); + XFree (text_prop.value); + return NULL; } } + XFree (text_prop.value); } else { PRINT_DEBUG (("I can't get the WMName.\n")); return NULL;