[gnome-control-center] Fix crash when iterating through the tree model



commit 5998aa90c08051cc520dfb64ede78783ef9cc2c4
Author: Jens Granseuer <jensgr gmx net>
Date:   Tue Aug 11 18:01:55 2009 +0200

    Fix crash when iterating through the tree model
    
    Don't use indices to move through iterators, don't skip the first
    section, and verify that we got a new iterator before using it
    (bug #591392).

 capplets/keybindings/gnome-keybinding-properties.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/capplets/keybindings/gnome-keybinding-properties.c b/capplets/keybindings/gnome-keybinding-properties.c
index fb3ba35..5383298 100644
--- a/capplets/keybindings/gnome-keybinding-properties.c
+++ b/capplets/keybindings/gnome-keybinding-properties.c
@@ -522,25 +522,20 @@ find_section (GtkTreeModel *model,
               GtkTreeIter  *iter,
 	      const char   *title)
 {
-  gint i, j;
-  gboolean found;
+  gboolean success, found;
 
-  i = gtk_tree_model_iter_n_children (model, NULL);
   found = FALSE;
-  gtk_tree_model_get_iter_first (model, iter);
-  for (j = 0; j < i; j++)
+  success = gtk_tree_model_get_iter_first (model, iter);
+  while (success && !found)
     {
       char *description = NULL;
 
-      gtk_tree_model_iter_next (model, iter);
       gtk_tree_model_get (model, iter,
 			  DESCRIPTION_COLUMN, &description,
 			  -1);
-      if (g_strcmp0 (description, title) == 0)
-        {
-	  found = TRUE;
-     	  break;
-        }
+
+      found = (g_strcmp0 (description, title) == 0);
+      success = gtk_tree_model_iter_next (model, iter);
     }
   if (!found)
     {



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