From: Michael Stapelberg Date: Tue, 28 Apr 2009 20:41:00 +0000 (+0200) Subject: Bugfix: Don’t crash when asprintf() can’t print the window name (Thanks ch3ka) X-Git-Tag: 3.a-bf1~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c689b93bce30afda8881746b4a0195452b74d8fc;p=i3%2Fi3 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. --- diff --git a/src/handlers.c b/src/handlers.c index d31d0f33..0102cb12 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -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 */ 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);