From eea81807ee03e46558ea92e656bb73dfee80ef2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 9 Jul 2019 11:49:18 +0200 Subject: [PATCH] test-utils: Only initialize client when we're returning it test_client_new might return early if conditions are not met, leaving some allocated data around without freeing it. Since we're not using the client before, there's no need to initialize it early and just initialize it when it's going to be returned. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195 (cherry picked from commit 506e06589b7feabd184b90bf5ac38ec83cefd92c) --- src/tests/test-utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c index cfade80c5..28cf97164 100644 --- a/src/tests/test-utils.c +++ b/src/tests/test-utils.c @@ -427,7 +427,7 @@ test_client_new (const char *id, MetaWindowClientType type, GError **error) { - TestClient *client = g_new0 (TestClient, 1); + TestClient *client; GSubprocessLauncher *launcher; GSubprocess *subprocess; MetaWaylandCompositor *compositor; @@ -462,6 +462,7 @@ test_client_new (const char *id, if (!subprocess) return NULL; + client = g_new0 (TestClient, 1); client->type = type; client->id = g_strdup (id); client->cancellable = g_cancellable_new ();