[gedit] Fix possible memory leak



commit 7638d411544c1f211816768adc1a5cb5a84db96a
Author: Daniel Trebbien <dtrebbien gmail com>
Date:   Sat Feb 11 18:19:09 2012 -0500

    Fix possible memory leak
    
    In treeview_selection_changed(), if `notebook` is not NULL, then it needs
    to be unrefed.
    
    See:  http://developer.gnome.org/gtk/unstable/GtkTreeModel.html#gtk-tree-model-get
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669913

 gedit/gedit-documents-panel.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/gedit/gedit-documents-panel.c b/gedit/gedit-documents-panel.c
index 5c01eae..682f741 100644
--- a/gedit/gedit-documents-panel.c
+++ b/gedit/gedit-documents-panel.c
@@ -617,9 +617,11 @@ treeview_selection_changed (GtkTreeSelection    *selection,
 		{
 			gedit_multi_notebook_set_active_tab (panel->priv->mnb,
 							     tab);
+			if (notebook != NULL)
+				g_object_unref (notebook);
 			g_object_unref (tab);
 		}
-		else
+		else if (notebook != NULL)
 		{
 			panel->priv->setting_active_notebook = TRUE;
 			gtk_widget_grab_focus (GTK_WIDGET (notebook));
@@ -633,6 +635,8 @@ treeview_selection_changed (GtkTreeSelection    *selection,
 						  G_CALLBACK (document_changed),
 						  panel);
 			}
+
+			g_object_unref (notebook);
 		}
 	}
 }



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