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: 74aefb0fd7 ("lib: Add internal helper for up_client_get_devices2()")
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
This commit is contained in:
Mathias Krause 2025-12-12 14:30:21 +01:00
parent c5df437cc1
commit 59f31ebed9

View file

@ -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;
}