From 71221baca0c0ce6111c93d3c74f09f870782e944 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 8 Mar 2009 20:04:01 +0100 Subject: [PATCH] Fix race condition when updating client->name --- src/handlers.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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) -- 2.39.5