xwayland: use strndup in xwm_get_atom_name

This commit is contained in:
emersion 2018-04-03 10:36:22 -04:00
parent d7e03c7adc
commit 1cd7ff7d3a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -517,12 +517,7 @@ char *xwm_get_atom_name(struct wlr_xwm *xwm, xcb_atom_t atom) {
}
size_t len = xcb_get_atom_name_name_length(name_reply);
char *buf = xcb_get_atom_name_name(name_reply); // not a C string
char *name = malloc((len + 1) * sizeof(char));
if (name == NULL) {
return NULL;
}
memcpy(name, buf, len);
name[len] = '\0';
char *name = strndup(buf, len);
free(name_reply);
return name;
}