JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
check to see if there is actual data to use before proceeding
authorDavid Hill <dhill@conformal.com>
Thu, 12 Jul 2012 21:14:47 +0000 (17:14 -0400)
committerReginald Kennedy <rk@rejii.com>
Fri, 20 Jul 2012 21:58:33 +0000 (05:58 +0800)
spectrwm.c

index 408efc2..92576fe 100644 (file)
@@ -3778,14 +3778,15 @@ get_win_name(xcb_window_t win)
 
        c = xcb_icccm_get_wm_name(conn, win);
        if (xcb_icccm_get_wm_name_reply(conn, c, &r, NULL)) {
-               name = malloc(r.name_len + 1);
-               if (!name) {
-                       xcb_get_text_property_reply_wipe(&r);
-                       return (NULL);
+               if (r.name_len > 0) {
+                       name = malloc(r.name_len + 1);
+                       if (!name) {
+                               xcb_get_text_property_reply_wipe(&r);
+                               return (NULL);
+                       }
+                       memcpy(name, r.name, r.name_len);
+                       name[r.name_len] = '\0';
                }
-               memcpy(name, r.name, r.name_len);
-               name[r.name_len] = '\0';
-               
                xcb_get_text_property_reply_wipe(&r);
        }