[gtk+] linkbutton: Fix memory leak



commit 00cd92ea71eae5d272f6f7cca58d71a29334ca4c
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Fri May 5 10:52:27 2017 +0530

    linkbutton: Fix memory leak
    
    strings returned by gtk_widget_get_tooltip_text() and
    gtk_widget_get_tooltip_markup() has to be freed when no longer
    required.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782202

 gtk/gtklinkbutton.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index ab58144..3c97a3e 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -599,18 +599,24 @@ gtk_link_button_query_tooltip_cb (GtkWidget    *widget,
 {
   GtkLinkButton *link_button = GTK_LINK_BUTTON (widget);
   const gchar *label, *uri;
+  gchar *text, *markup;
 
   label = gtk_button_get_label (GTK_BUTTON (link_button));
   uri = link_button->priv->uri;
+  text = gtk_widget_get_tooltip_text (widget);
+  markup = gtk_widget_get_tooltip_markup (widget);
 
-  if (!gtk_widget_get_tooltip_text (widget)
-    && !gtk_widget_get_tooltip_markup (widget)
-    && label && *label != '\0' && uri && strcmp (label, uri) != 0)
+  if (text == NULL &&
+      markup == NULL &&
+      label && *label != '\0' && uri && strcmp (label, uri) != 0)
     {
       gtk_tooltip_set_text (tooltip, uri);
       return TRUE;
     }
 
+  g_free (text);
+  g_free (markup);
+
   return FALSE;
 }
 


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