From 6cd3d19ae965d3fcc00e71fef25124c46b702242 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 5 Sep 2025 14:37:17 +0200 Subject: [PATCH] libnm-client: fix memory leak The test calls g_main_context_ref() on client_context, which must then be unreferenced. Fixes: 88724ff169a1 ('libnm: add nm_client_wait_shutdown() function for cleaning up NMClient') (cherry picked from commit d559f61423fe9fd26c078acb2bb39b723394296c) --- src/libnm-client-impl/tests/test-nm-client.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libnm-client-impl/tests/test-nm-client.c b/src/libnm-client-impl/tests/test-nm-client.c index 39831509b9..da252549a7 100644 --- a/src/libnm-client-impl/tests/test-nm-client.c +++ b/src/libnm-client-impl/tests/test-nm-client.c @@ -1432,13 +1432,13 @@ test_client_wait_shutdown(void) nmtst_assert_success(dbus_connection, error); for (i_run = 0; i_run < N_RUN; i_run++) { - gs_unref_object GCancellable *init_cancellable = g_cancellable_new(); - gs_unref_object NMClient *nmc = NULL; - nm_auto_pop_gmaincontext GMainContext *client_context = NULL; - gboolean b; - gboolean context_integrated = FALSE; - gs_unref_object GCancellable *cancellable_1 = NULL; - GMainContext *ctx; + gs_unref_object GCancellable *init_cancellable = g_cancellable_new(); + gs_unref_object NMClient *nmc = NULL; + nm_auto_pop_and_unref_gmaincontext GMainContext *client_context = NULL; + gboolean b; + gboolean context_integrated = FALSE; + gs_unref_object GCancellable *cancellable_1 = NULL; + GMainContext *ctx; /* Choose a random context for the client. */ ctx = contexts->pdata[nmtst_get_rand_uint32() % contexts->len];