From 59f31ebed918ec51546e5ce844d1ef5d07f1c867 Mon Sep 17 00:00:00 2001 From: Mathias Krause Date: Fri, 12 Dec 2025 14:30:21 +0100 Subject: [PATCH] lib: Fix error handling in up_client_get_devices2() In case the assert in up_client_get_devices_full() triggers, 'error' will still be NULL, making the code cause a NULL pointer dereference when trying to emit a warning. Ensure 'error' is non-NULL when trying to generate the warning. If it's NULL, the failing assert in up_client_get_devices_full() will have generated an appropriate message already. Fixes: 74aefb0fd7d7 ("lib: Add internal helper for up_client_get_devices2()") Signed-off-by: Mathias Krause --- libupower-glib/up-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 528e8e7..5417fa4 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -150,7 +150,7 @@ up_client_get_devices2 (UpClient *client) ret = up_client_get_devices_full (client, NULL, &error); if (!ret) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("up_client_get_devices failed: %s", error->message); return NULL; }