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);
}