After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 97927 - gtk_tree_view_expand_to_path accidently modifies and then frees the path passed to it and crashes
gtk_tree_view_expand_to_path accidently modifies and then frees the path pass...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.1.x
Other Linux
: Normal critical
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks:
 
 
Reported: 2002-11-07 14:00 UTC by Erik Simonsen
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Erik Simonsen 2002-11-07 14:00:44 UTC
gtk_tree_view_expand_to_path is passed a treeview and a path variable.  A new TreePath, temp is declared to be used as a temporary path for 
expanding the parents of the function's arguement, path.  The function, however, ignores temp, and performs all of it's operations on the 
function arguement, finally freeing it before returning.  Not only will the tree not be expanded properly, but the program will segfault 
when the program tries to free the path that was passed to the function.

the function looks like this:

void
gtk_tree_view_expand_to_path (GtkTreeView *tree_view,
                  GtkTreePath *path)
{
  gint i, depth;
  gint *indices;
  GtkTreePath *tmp;

  g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
  g_return_if_fail (path != NULL);

  depth = gtk_tree_path_get_depth (path);
  indices = gtk_tree_path_get_indices (path);

  tmp = gtk_tree_path_new ();
  g_return_if_fail (tmp != NULL);

  for (i = 0; i < depth; i++)
    {
      gtk_tree_path_append_index (path, indices[i]);
      gtk_tree_view_expand_row (tree_view, path, FALSE);
    }

  gtk_tree_path_free (path);
}

/*********************************************************/
but should be modified so the for loop looks like this:

  for (i = 0; i < depth; i++)
    {
      gtk_tree_path_append_index (tmp, indices[i]);
      gtk_tree_view_expand_row (tree_view, tmp, FALSE);
    }

  gtk_tree_path_free (tmp);
}
Comment 1 Kristian Rietveld 2002-11-18 19:38:34 UTC
committed, thanks for the patch. Include your realname in your
bugzilla account if you want ChangeLog credit next time.