[Xfce4-commits] [xfce/xfce4-power-manager] 01/01: plugin: Fix a couple memory leaks (Bug #12332)

noreply at xfce.org noreply at xfce.org
Mon Jan 4 04:57:01 CET 2016


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 6eaf8f868ed9ed8018385e16a92eaacef3c32a9d
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Mon Dec 28 16:12:00 2015 +0300

    plugin: Fix a couple memory leaks (Bug #12332)
    
    Found a couple spots where we inadvertently leak memory.
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 .../power-manager-plugin/power-manager-button.c    |   26 +++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/panel-plugins/power-manager-plugin/power-manager-button.c b/panel-plugins/power-manager-plugin/power-manager-button.c
index acec909..5135ba4 100644
--- a/panel-plugins/power-manager-plugin/power-manager-button.c
+++ b/panel-plugins/power-manager-plugin/power-manager-button.c
@@ -320,6 +320,7 @@ power_manager_button_set_label (PowerManagerButton *button, gdouble percentage,
     gtk_label_set_text (GTK_LABEL (button->priv->panel_label), label_string);
 
     g_free (label_string);
+    g_free (remaining_time);
 }
 
 static gboolean
@@ -454,7 +455,14 @@ power_manager_button_update_device_icon_and_details (PowerManagerButton *button,
     details = get_device_description (button->priv->upower, device);
 
     /* If UPower doesn't give us an icon, just use the default */
-    if (icon_name == NULL || g_strcmp0(icon_name, "") == 0)
+    if (g_strcmp0(icon_name, "") == 0)
+    {
+        /* ignore empty icon names */
+        g_free (icon_name);
+        icon_name = NULL;
+    }
+
+    if (icon_name == NULL)
         icon_name = g_strdup (PANEL_DEFAULT_ICON);
 
     pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
@@ -483,7 +491,15 @@ power_manager_button_update_device_icon_and_details (PowerManagerButton *button,
         g_object_get (device,
                       "icon-name", &icon_name,
                       NULL);
-        if (icon_name == NULL || g_strcmp0(icon_name, "") == 0)
+
+        /* ignore empty icon names */
+        if (g_strcmp0(icon_name, "") == 0)
+        {
+            g_free (icon_name);
+            icon_name = NULL;
+        }
+
+        if (icon_name == NULL)
             icon_name = g_strdup (PANEL_DEFAULT_ICON_SYMBOLIC);
 #endif
         button->priv->panel_icon_name = g_strdup (icon_name);
@@ -503,7 +519,7 @@ power_manager_button_update_device_icon_and_details (PowerManagerButton *button,
         /* update the image, keep track of the signal ids and the img
          * so we can disconnect it later */
         battery_device->img = gtk_image_new_from_pixbuf (battery_device->pix);
-        g_object_ref (battery_device->img);
+
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
         gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(battery_device->menu_item), battery_device->img);
 G_GNUC_END_IGNORE_DEPRECATIONS
@@ -604,6 +620,8 @@ remove_battery_device (PowerManagerButton *button, BatteryDevice *battery_device
     g_free (battery_device->details);
     g_free (battery_device->object_path);
 
+    battery_device_remove_pix (battery_device);
+
     if (battery_device->device != NULL && UP_IS_DEVICE(battery_device->device))
     {
         /* disconnect the signal handler if we were using it */
@@ -614,6 +632,8 @@ remove_battery_device (PowerManagerButton *button, BatteryDevice *battery_device
         g_object_unref (battery_device->device);
         battery_device->device = NULL;
     }
+
+    g_free (battery_device);
 }
 
 static void

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list