Bugfix: Don’t crash when asprintf() can’t print the window name (Thanks ch3ka)
Apparantly, under some conditions (using LANG=en_US.UTF-8, other locale variables unset), asprintf() says "Invalid or incomplete multibyte or wide character" when given a string in COMPOUND_TEXT encoding. For now, we properly handle asprintf-errors (this should have been before), but there might be a better solution.
This commit is contained in:
parent
fdf639ed1d
commit
c689b93bce
|
@ -747,7 +747,11 @@ int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t
|
||||||
|
|
||||||
/* Save the old pointer to make the update atomic */
|
/* Save the old pointer to make the update atomic */
|
||||||
char *new_name;
|
char *new_name;
|
||||||
asprintf(&new_name, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop));
|
if (asprintf(&new_name, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)) == -1) {
|
||||||
|
perror("Could not get old name");
|
||||||
|
LOG("Could not get old name\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */
|
/* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */
|
||||||
LOG("Name should change to \"%s\"\n", new_name);
|
LOG("Name should change to \"%s\"\n", new_name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue