summaryrefslogtreecommitdiff
path: root/thunarx
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2010-10-04 16:20:33 +0200
committerJannis Pohlmann <jannis@xfce.org>2010-10-04 16:20:33 +0200
commit14d505a1aa9d95ffe290bb3b3f207e827f321417 (patch)
tree15ca8fe8d5f85a4c13c85a81d3dafaa61a447b5a /thunarx
parent1efc09d5f092530df07f4164137e4ec87824a8d1 (diff)
downloadthunar-14d505a1aa9d95ffe290bb3b3f207e827f321417.tar.gz
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.
Diffstat (limited to 'thunarx')
-rw-r--r--thunarx/thunarx-file-info.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/thunarx/thunarx-file-info.c b/thunarx/thunarx-file-info.c
index 56460244..0c0c5eb8 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);
+ }
+}