From 71bf3bc6aa5acbf9a0d6518d49795b8f081ca524 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Tue, 15 May 2012 11:10:24 -0400
Subject: [PATCH] * #10736: calltree: validate path when we are dropping into
 an element

---
 gnome/src/contacts/calltree.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c
index 38071ea86f..7063be4991 100644
--- a/gnome/src/contacts/calltree.c
+++ b/gnome/src/contacts/calltree.c
@@ -1246,22 +1246,6 @@ render_drop(GtkTreeModel *model, GtkTreePath *dest_path, GtkTreeViewDropPosition
         return FALSE;
     }
 
-    GtkTreePath *source_path = gtk_tree_model_get_path(model, source_iter);
-    if (!gtk_tree_path_compare(source_path, dest_path)) {
-        ERROR("invalid drop: source and dest are same");
-        gtk_tree_path_free(source_path);
-        return FALSE;
-    } else if (gtk_tree_path_is_ancestor(source_path, dest_path)) {
-        ERROR("invalid drop: source is ancestor of dest");
-        gtk_tree_path_free(source_path);
-        return FALSE;
-    } else if (gtk_tree_path_is_descendant(source_path, dest_path)) {
-        ERROR("invalid drop: source is descendant of dest");
-        gtk_tree_path_free(source_path);
-        return FALSE;
-    }
-    gtk_tree_path_free(source_path);
-
     gboolean result;
     switch (dest_pos) {
         case GTK_TREE_VIEW_DROP_BEFORE:
@@ -1272,6 +1256,22 @@ render_drop(GtkTreeModel *model, GtkTreePath *dest_path, GtkTreeViewDropPosition
             /* fallthrough */
         case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
             DEBUG("DROP_INTO");
+            GtkTreePath *source_path = gtk_tree_model_get_path(model, source_iter);
+            if (!gtk_tree_path_compare(source_path, dest_path)) {
+                ERROR("invalid drop: source and dest are same");
+                gtk_tree_path_free(source_path);
+                return FALSE;
+            } else if (gtk_tree_path_is_ancestor(source_path, dest_path)) {
+                ERROR("invalid drop: source is ancestor of dest");
+                gtk_tree_path_free(source_path);
+                return FALSE;
+            } else if (gtk_tree_path_is_descendant(source_path, dest_path)) {
+                ERROR("invalid drop: source is descendant of dest");
+                gtk_tree_path_free(source_path);
+                return FALSE;
+            }
+            gtk_tree_path_free(source_path);
+
             result = handle_drop_into(model, source_iter, &dest_iter);
             break;
         case GTK_TREE_VIEW_DROP_AFTER:
-- 
GitLab