[nautilus] toolbar: Don't leak previous allocations



commit ec52282f157803585ff92c888e5b2c0b0fb76c5b
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Tue May 2 22:44:07 2017 +0530

    toolbar: Don't leak previous allocations
    
    When undo_active/redo_active is FALSE, undo_label/redo_label
    was getting overwritten irrespective of whether they were
    NULL or not.
    
    Let the label values be freed incase they are updated.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782083

 src/nautilus-toolbar.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index e78dffe..c8c5834 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -853,10 +853,18 @@ undo_manager_changed (NautilusToolbar *self)
 
     /* Set the label of the undo and redo menu items, and activate them appropriately
      */
-    undo_label = undo_active && undo_label != NULL ? undo_label : g_strdup (_("_Undo"));
+    if (!undo_active || undo_label == NULL)
+    {
+        g_free (undo_label);
+        undo_label = g_strdup (_("_Undo"));
+    }
     update_menu_item (self->undo_button, self, "undo", undo_active, undo_label);
 
-    redo_label = redo_active && redo_label != NULL ? redo_label : g_strdup (_("_Redo"));
+    if (!redo_active || redo_label == NULL)
+    {
+        g_free (redo_label);
+        redo_label = g_strdup (_("_Redo"));
+    }
     update_menu_item (self->redo_button, self, "redo", redo_active, redo_label);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]