* src/widgets/modest-dnd.c
authorAlberto Garcia <agarcia@igalia.com>
Fri, 29 Feb 2008 15:50:14 +0000 (15:50 +0000)
committerAlberto Garcia <agarcia@igalia.com>
Fri, 29 Feb 2008 15:50:14 +0000 (15:50 +0000)
(modest_dnd_selection_data_set_paths):
Don't crash if selected_rows is an empty list
Fixes NB#81573

pmo-trunk-r4258

src/widgets/modest-dnd.c

index 291239f..6c40d8b 100644 (file)
@@ -50,20 +50,18 @@ modest_dnd_selection_data_set_paths (GtkSelectionData *selection_data,
 
        if (selection_data->target == tree_path_as_string_list_atom) {
                GString *list;
-               gint i;
                gchar *result;
                GList *row;
       
                row = selected_rows;
                list = g_string_new (NULL);
                
-               for (i = 0; i<g_list_length(selected_rows) - 1; i++) {
+               while (row != NULL) {
                        g_string_append (list, gtk_tree_path_to_string (row->data));
-                       g_string_append (list, "\n");
                        row = g_list_next (row);
+                       if (row != NULL)
+                               g_string_append (list, "\n");
                }
-               /* Do not include the delimiter in the last one */
-               g_string_append (list, gtk_tree_path_to_string (row->data));
 
                result = g_strdup (list->str);
                g_string_free (list, TRUE);