mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
xwayland: use strndup in xwm_get_atom_name
This commit is contained in:
parent
d7e03c7adc
commit
1cd7ff7d3a
1 changed files with 1 additions and 6 deletions
|
@ -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);
|
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 *buf = xcb_get_atom_name_name(name_reply); // not a C string
|
||||||
char *name = malloc((len + 1) * sizeof(char));
|
char *name = strndup(buf, len);
|
||||||
if (name == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memcpy(name, buf, len);
|
|
||||||
name[len] = '\0';
|
|
||||||
free(name_reply);
|
free(name_reply);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue