From 9d81da62f2c075f2ff8b226e0d914fc6ef4f4125 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 18 Feb 2025 15:04:06 +0000 Subject: [PATCH] tests: Fix a minor leak in a new GSubprocess test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And also rearrange the asserts so that the error is checked first (since that’s the more informative failure to receive if the test did fail). Spotted by Marco in https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4494#note_2352013 and by The Machines in https://gitlab.gnome.org/GNOME/glib/-/jobs/4768121. Signed-off-by: Philip Withnall --- gio/tests/gsubprocess.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c index cdda4e052..2d38b41b2 100644 --- a/gio/tests/gsubprocess.c +++ b/gio/tests/gsubprocess.c @@ -1356,16 +1356,16 @@ static void test_fail_initialization (void) { GError *local_error = NULL; - GError **error = &local_error; GSubprocess *proc; proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE, - error, + &local_error, "thisprogramshouldnotexistprettyplease", NULL); - g_assert_null (proc); g_assert_error (local_error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT); + g_assert_null (proc); + g_clear_error (&local_error); } #ifdef G_OS_UNIX