]> git.pld-linux.org Git - packages/xfce4-power-manager.git/blob - 0203-Fix-uninitialized-pointer-read.patch
- updated from git, upower 0.99 and systemd support added
[packages/xfce4-power-manager.git] / 0203-Fix-uninitialized-pointer-read.patch
1 From 6189440308723dd72fa9a97a0f19db34083c95a9 Mon Sep 17 00:00:00 2001
2 From: Eric Koegel <eric.koegel@gmail.com>
3 Date: Tue, 29 Apr 2014 08:00:17 +0300
4 Subject: [PATCH 203/219] Fix uninitialized pointer read
5
6 The tip pointer could be used uninitialized when the device state
7 is unknown. Also tooltips are now shown for all device types rather
8 than just UPS and battery (i.e. for the mouse/keyboard icons). This
9 should prevent some confustion over what the other icons represent.
10 ---
11  src/xfpm-battery.c | 33 ++++++++++++++++++++++-----------
12  1 file changed, 22 insertions(+), 11 deletions(-)
13
14 diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
15 index 603c8de..3a246ad 100644
16 --- a/src/xfpm-battery.c
17 +++ b/src/xfpm-battery.c
18 @@ -405,16 +405,25 @@ xfpm_battery_notify_state (XfpmBattery *battery)
19  }
20  
21  /*
22 - * Refresh tooltip function for UPS and battery device only.
23 + * Refresh tooltip function for devices with a battery.
24   */
25  static void
26  xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
27  {
28 -    gchar *tip;
29 +    gchar *tip = NULL;
30      gchar *est_time_str = NULL;
31      gchar *power_status = NULL;
32  
33 -    power_status = g_strdup_printf (battery->priv->ac_online ? _("Adaptor is online") : _("System is running on battery power"));
34 +    if ( battery->priv->type == UP_DEVICE_KIND_BATTERY ||
35 +         battery->priv->type == UP_DEVICE_KIND_UPS )
36 +    {
37 +        power_status = g_strdup_printf (battery->priv->ac_online ? _("Adaptor is online") : _("System is running on battery power"));
38 +    }
39 +    else
40 +    {
41 +       /* Let the user know it's not a system battery being monitored */
42 +        power_status = g_strdup(_("Peripheral Device"));
43 +    }
44  
45      if ( battery->priv->state == UP_DEVICE_STATE_FULLY_CHARGED )
46      {
47 @@ -489,6 +498,14 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
48      {
49         tip = g_strdup_printf (_("%s\nYour %s is empty"), power_status, battery->priv->battery_name);
50      }
51 +    else
52 +    {
53 +       /* unknown device state, just display the percentage */
54 +       tip = g_strdup_printf (_("%s\nYour %s is at (%i%%)."),
55 +                                  power_status,
56 +                                  battery->priv->battery_name,
57 +                                  battery->priv->percentage);
58 +    }
59  
60      gtk_tooltip_set_text (tooltip, tip);
61      g_free (power_status);
62 @@ -592,14 +609,8 @@ xfpm_battery_query_tooltip (GtkStatusIcon *icon,
63  
64      battery = XFPM_BATTERY (icon);
65  
66 -    if ( battery->priv->type == UP_DEVICE_KIND_BATTERY ||
67 -        battery->priv->type == UP_DEVICE_KIND_UPS )
68 -    {
69 -       xfpm_battery_set_tooltip_primary (battery, tooltip);
70 -       return TRUE;
71 -    }
72 -
73 -    return FALSE;
74 +    xfpm_battery_set_tooltip_primary (battery, tooltip);
75 +    return TRUE;
76  }
77  
78  static void
79 -- 
80 1.9.3
81
This page took 0.134623 seconds and 3 git commands to generate.