GNOME Bugzilla – Bug 97927
gtk_tree_view_expand_to_path accidently modifies and then frees the path passed to it and crashes
Last modified: 2004-12-22 21:47:04 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); }
committed, thanks for the patch. Include your realname in your bugzilla account if you want ChangeLog credit next time.