]> git.sur5r.net Git - i3/i3/commitdiff
Fix race condition when updating client->name
authorMichael Stapelberg <michael+git@stapelberg.de>
Sun, 8 Mar 2009 19:04:01 +0000 (20:04 +0100)
committerMichael Stapelberg <michael+git@stapelberg.de>
Sun, 8 Mar 2009 19:04:01 +0000 (20:04 +0100)
src/handlers.c

index 1c88268815758ca0ee7f4cccd316b7e347c5ce38..39bb89c268683054ddb10f08f265beedee54dca4 100644 (file)
@@ -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)