changeset 998:d2701a5864c5

Fixed segfault when is run inside directory with non valid uft-8 image filename.
author bruclik
date Tue, 26 Aug 2008 20:21:30 +0000
parents c74c4e87a682
children bbed8e9a5d33
files src/filedata.c src/ui_fileops.c
diffstat 2 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Tue Aug 26 13:56:56 2008 +0000
+++ b/src/filedata.c	Tue Aug 26 20:21:30 2008 +0000
@@ -149,22 +149,22 @@
 static void file_data_set_collate_keys(FileData *fd)
 {
 	gchar *caseless_name;
-
-	g_assert(g_utf8_validate(fd->name, -1, NULL));
-
-	caseless_name = g_utf8_casefold(fd->name, -1);
+	gchar *name = path_to_utf8(fd->name);
+	
+	caseless_name = g_utf8_casefold(name, -1);
 
 	g_free(fd->collate_key_name);
 	g_free(fd->collate_key_name_nocase);
 
 #if GLIB_CHECK_VERSION(2, 8, 0)
-	fd->collate_key_name = g_utf8_collate_key_for_filename(fd->name, -1);
+	fd->collate_key_name = g_utf8_collate_key_for_filename(name, -1);
 	fd->collate_key_name_nocase = g_utf8_collate_key_for_filename(caseless_name, -1);
 #else
-	fd->collate_key_name = g_utf8_collate_key(fd->name, -1);
+	fd->collate_key_name = g_utf8_collate_key(name, -1);
 	fd->collate_key_name_nocase = g_utf8_collate_key(caseless_name, -1);
 #endif
 	g_free(caseless_name);
+	g_free(name);
 }
 
 static void file_data_set_path(FileData *fd, const gchar *path)
--- a/src/ui_fileops.c	Tue Aug 26 13:56:56 2008 +0000
+++ b/src/ui_fileops.c	Tue Aug 26 20:21:30 2008 +0000
@@ -172,20 +172,16 @@
 	return path;
 }
 
-/* first we try the HOME environment var, if that doesn't work, we try getpwuid(). */
+/* first we try the HOME environment var, if that doesn't work, we try g_get_homedir(). */
 const gchar *homedir(void)
 {
 	static gchar *home = NULL;
 
 	if (!home)
-		{
 		home = path_to_utf8(getenv("HOME"));
-		}
+	
 	if (!home)
-		{
-		struct passwd *pw = getpwuid(getuid());
-		if (pw) home = path_to_utf8(pw->pw_dir);
-		}
+		home = path_to_utf8(g_get_home_dir());
 
 	return home;
 }