xcb: use strncpy() to extract atom name

This commit is contained in:
Daniel Eklöf 2019-01-19 12:18:54 +01:00
parent 04f7f3485f
commit 7bb849bdf4

6
xcb.c
View file

@ -191,10 +191,8 @@ get_atom_name(xcb_connection_t *conn, xcb_atom_t atom)
return NULL;
}
int len = xcb_get_atom_name_name_length(reply);
char *name = malloc(len + 1);
memcpy(name, xcb_get_atom_name_name(reply), len);
name[len] = '\0';
char *name = strndup(
xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
LOG_DBG("atom name: %s", name);