summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-02-01 12:11:00 +0100
committerBastien Nocera <hadess@hadess.net>2021-02-04 09:45:50 +0000
commit706dcd44e443f630607554b1154a5d3685d43a9c (patch)
treee2db3c74646527bf72d134efdf259e07df7b5ef4 /tools
parent4b96535023d5bdbc6df0b81b9e6e315e47ceb8a8 (diff)
downloadupower-706dcd44e443f630607554b1154a5d3685d43a9c.tar.gz
up-tool: Catch NULL return for more upower API calls
This can lead to crashes if the communication with the daemon fails. See https://bugzilla.redhat.com/show_bug.cgi?id=1922777
Diffstat (limited to 'tools')
-rw-r--r--tools/up-tool.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/up-tool.c b/tools/up-tool.c
index 724e468..5e73cc5 100644
--- a/tools/up-tool.c
+++ b/tools/up-tool.c
@@ -315,6 +315,10 @@ main (int argc, char **argv)
if (opt_enumerate || opt_dump) {
GPtrArray *devices;
devices = up_client_get_devices2 (client);
+ if (!devices) {
+ g_print ("Failed to get device list\n");
+ goto out;
+ }
for (i=0; i < devices->len; i++) {
device = (UpDevice*) g_ptr_array_index (devices, i);
if (opt_enumerate) {
@@ -328,6 +332,10 @@ main (int argc, char **argv)
}
g_ptr_array_unref (devices);
device = up_client_get_display_device (client);
+ if (!device) {
+ g_print ("Failed to get display device\n");
+ goto out;
+ }
if (opt_enumerate) {
g_print ("%s\n", up_device_get_object_path (device));
} else {