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.
/* Save the old pointer to make the update atomic */
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 */
LOG("Name should change to \"%s\"\n", new_name);