diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2015-03-28 10:59:18 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2015-03-29 15:34:50 +0300 |
commit | f6c58f4520f36c5cab3e3192bf3f9b6d4ec21cdb (patch) | |
tree | 6d1b9af83abb13175a503aed1fbee7a47aef57df /common | |
parent | 5892136939f37c63fecee7c0700cfcf9ce7a3e97 (diff) | |
download | ixfce4-power-manager-f6c58f4520f36c5cab3e3192bf3f9b6d4ec21cdb.tar.gz |
Don't crash when UPower returns "" for the icon-name (Bug #11756)
I assume this is for devices UPower doesn't know anything about?
Diffstat (limited to 'common')
-rw-r--r-- | common/xfpm-power-common.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/common/xfpm-power-common.c b/common/xfpm-power-common.c index 43fc7314..c9df21e2 100644 --- a/common/xfpm-power-common.c +++ b/common/xfpm-power-common.c @@ -29,6 +29,7 @@ #include "xfpm-enum-glib.h" #include "xfpm-icons.h" +#include "xfpm-debug.h" /** @@ -176,7 +177,17 @@ get_device_icon_name (UpClient *upower, UpDevice *device) /* Strip away the symbolic suffix for the device icons for the devices tab * and the panel plugin's menu */ icon_suffix = g_strrstr (upower_icon, "-symbolic"); - icon_base_length = icon_suffix - upower_icon; + if (icon_suffix != NULL) + { + icon_base_length = icon_suffix - upower_icon; + } + else + { + icon_base_length = G_MAXINT; + } + + XFPM_DEBUG ("icon_suffix %s, icon_base_length %ld, upower_icon %s", + icon_suffix, icon_base_length, upower_icon); /* mapped from * http://cgit.freedesktop.org/upower/tree/libupower-glib/up-types.h @@ -202,7 +213,7 @@ get_device_icon_name (UpClient *upower, UpDevice *device) icon_name = g_strdup (XFPM_TABLET_ICON); else if ( type == UP_DEVICE_KIND_COMPUTER ) icon_name = g_strdup (XFPM_COMPUTER_ICON); - else + else if ( g_strcmp0 (upower_icon, "") != 0 ) icon_name = g_strndup (upower_icon, icon_base_length); return icon_name; |