From: Michael Stapelberg Date: Sun, 8 Mar 2009 19:04:01 +0000 (+0100) Subject: Fix race condition when updating client->name X-Git-Tag: 3.a~60 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=71221baca0c0ce6111c93d3c74f09f870782e944;p=i3%2Fi3 Fix race condition when updating client->name --- diff --git a/src/handlers.c b/src/handlers.c index 1c882688..39bb89c2 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -483,10 +483,11 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state, if (client == NULL) return 1; - if (client->name != NULL) - free(client->name); - + /* Save the old pointer to make the update atomar */ + char *old_name = client->name; asprintf(&(client->name), "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)); + if (old_name != NULL) + free(old_name); LOG("rename to \"%s\".\n", client->name); if (client->container->mode == MODE_STACK)