Fix race condition when updating client->name

This commit is contained in:
Michael Stapelberg 2009-03-08 20:04:01 +01:00
parent 9e74378dd0
commit 71221baca0
1 changed files with 4 additions and 3 deletions

View File

@ -483,10 +483,11 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
if (client == NULL) if (client == NULL)
return 1; return 1;
if (client->name != NULL) /* Save the old pointer to make the update atomar */
free(client->name); char *old_name = client->name;
asprintf(&(client->name), "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)); 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); LOG("rename to \"%s\".\n", client->name);
if (client->container->mode == MODE_STACK) if (client->container->mode == MODE_STACK)