From 991a7d9433373196b33028b7ed7b48c5d75b9801 Mon Sep 17 00:00:00 2001 From: Kate Hsuan Date: Fri, 23 Jan 2026 16:23:43 +0800 Subject: [PATCH] libupower-glib: up-client: Fix crash when printing the error message from a NULL GError pointer Passing a NULL UpClient to up_client_get_devices2() led to the following error message since up_client_get_devices_full() returned immediately without properly setting up a GError with the reasons for the error. (upower:21076): libupower-glib-CRITICAL **: 16:33:53.919: up_client_get_devices_full: assertion 'UP_IS_CLIENT (client)' failed Segmentation fault (core dumped) ./upower -d Related: https://gitlab.freedesktop.org/upower/upower/-/merge_requests/296 --- libupower-glib/up-client.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 663f1c6..83b033b 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -106,7 +106,15 @@ up_client_get_devices_full (UpClient *client, GPtrArray *array; guint i; - g_return_val_if_fail (UP_IS_CLIENT (client), NULL); + if (!UP_IS_CLIENT (client)) { + g_set_error (error, G_IO_ERROR, + G_IO_ERROR_INVALID_ARGUMENT, + "Invalid UpClient object"); + g_return_if_fail_warning (G_LOG_DOMAIN, + G_STRFUNC, + "UP_IS_CLIENT (client)"); + return NULL; + } if (up_exported_daemon_call_enumerate_devices_sync (client->priv->proxy, &devices,