summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2012-06-14 13:12:04 +0200
committerMartin Pitt <martinpitt@gnome.org>2012-06-14 13:18:10 +0200
commit48edf2f1a8df125794a452034ccf9b48d9c8eead (patch)
tree489803f8f0ece8e334561b01c145d1cba2197f20
parent55569ac40f1756b879a5ee676925be7bbd985588 (diff)
Fix wrong PowerSupply property for devices without a scope sysfs attribute
Fix NULL pointer comparison in up_device_supply_coldplug(). This caused (lt-upowerd:5754): GLib-CRITICAL **: g_ascii_strcasecmp: assertion `s1 != NULL' failed when a device does not have a "scope" sysfs attribute, and erroneously considering that device to not power the system. https://launchpad.net/bugs/1012578
-rw-r--r--src/linux/up-device-supply.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 48f5156..ec2514a 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -863,9 +863,9 @@ up_device_supply_coldplug (UpDevice *device)
/* try to work out if the device is powering the system */
scope = g_udev_device_get_sysfs_attr (native, "scope");
- if (g_ascii_strcasecmp (scope, "device") == 0) {
+ if (scope != NULL && g_ascii_strcasecmp (scope, "device") == 0) {
supply->priv->is_power_supply = FALSE;
- } else if (g_ascii_strcasecmp (scope, "system") == 0) {
+ } else if (scope != NULL && g_ascii_strcasecmp (scope, "system") == 0) {
supply->priv->is_power_supply = TRUE;
} else {
g_debug ("taking a guess for power supply scope");