]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
anvil: Fix memory leak when kicking clients
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 22 Oct 2025 18:19:29 +0000 (21:19 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 24 Oct 2025 07:24:21 +0000 (07:24 +0000)
src/anvil/admin-client-pool.c

index d4b6e3177a15bdc4442a43869bd4457803f8bc3f..83511a4bca9220c9eced892d4c15caeeb9762b30 100644 (file)
@@ -45,6 +45,7 @@ void admin_client_pool_deinit(struct admin_client_pool **_pool)
        array_foreach_elem(&pool->clients, client) {
                i_assert(client->refcount == 0);
                admin_client_unref(&client->client);
+               i_free(client);
        }
        array_free(&pool->clients);
        i_free(pool->base_dir);
@@ -64,8 +65,11 @@ static void admin_client_pool_cleanup(struct admin_client_pool *pool)
                        break;
                if (pool->idle_connection_count == 0)
                        break;
-               if (clients[i-1]->refcount == 0) {
-                       admin_client_unref(&clients[i-1]->client);
+
+               struct admin_client_ref *client = clients[i-1];
+               if (client->refcount == 0) {
+                       admin_client_unref(&client->client);
+                       i_free(client);
                        array_delete(&pool->clients, i-1, 1);
                }
        }