[Xfce4-commits] <thunar:master> Improve thunarx_file_info_list_copy() and thunarx_file_info_list_free().

Jannis Pohlmann noreply at xfce.org
Mon Oct 4 17:32:01 CEST 2010


Updating branch refs/heads/master
         to 14d505a1aa9d95ffe290bb3b3f207e827f321417 (commit)
       from 1efc09d5f092530df07f4164137e4ec87824a8d1 (commit)

commit 14d505a1aa9d95ffe290bb3b3f207e827f321417
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Oct 4 16:20:33 2010 +0200

    Improve thunarx_file_info_list_copy() and thunarx_file_info_list_free().
    
    These methods now check whether the input list is NULL and no longer
    segfault when it is. This makes it possible to copy and free empty lists
    without wrapping the calls to these methods with a NULL check.

 thunarx/thunarx-file-info.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/thunarx/thunarx-file-info.c b/thunarx/thunarx-file-info.c
index 5646024..0c0c5eb 100644
--- a/thunarx/thunarx-file-info.c
+++ b/thunarx/thunarx-file-info.c
@@ -421,8 +421,11 @@ thunarx_file_info_list_copy (GList *file_infos)
   GList *list = NULL;
   GList *lp;
 
-  for (lp = g_list_last (file_infos); lp != NULL; lp = lp->prev)
-    list = g_list_prepend (list, g_object_ref (G_OBJECT (lp->data)));
+  if (file_infos != NULL)
+    {
+      for (lp = g_list_last (file_infos); lp != NULL; lp = lp->prev)
+        list = g_list_prepend (list, g_object_ref (G_OBJECT (lp->data)));
+    }
 
   return list;
 }
@@ -440,6 +443,9 @@ thunarx_file_info_list_copy (GList *file_infos)
 void
 thunarx_file_info_list_free (GList *file_infos)
 {
-  g_list_foreach (file_infos, (GFunc) g_object_unref, NULL);
-  g_list_free (file_infos);
-}
+  if (file_infos != NULL)
+    {
+      g_list_foreach (file_infos, (GFunc) g_object_unref, NULL);
+      g_list_free (file_infos);
+    }
+}   



More information about the Xfce4-commits mailing list