power: Fix possible crash if up_client_get_devices() fails

up_client_get_devices() can fail if upower crashes or isn't available.
Make sure not to crash ourselves by handling NULL return values as we do
later in the loop.

See https://bugzilla.redhat.com/show_bug.cgi?id=1175421

https://bugzilla.gnome.org/show_bug.cgi?id=751095
This commit is contained in:
Bastien Nocera 2015-06-17 10:53:07 +02:00
parent dbe6eb9bbf
commit d2c0b66275

View file

@ -1136,7 +1136,7 @@ set_ac_battery_ui_mode (CcPowerPanel *self)
UpDeviceKind kind;
devices = up_client_get_devices (self->priv->up_client);
g_debug ("got %d devices from upower\n", devices->len);
g_debug ("got %d devices from upower\n", devices ? devices->len : 0);
for (i = 0; devices != NULL && i < devices->len; i++)
{