Fix crash when loading collection listing inexistent files.
authorLaurent Monin <zas@norz.org>
Mon, 26 Nov 2012 08:29:17 +0000 (09:29 +0100)
committerLaurent Monin <zas@norz.org>
Thu, 13 Dec 2012 11:40:16 +0000 (12:40 +0100)
src/collect.c
src/filedata.c

index c69155d..e3c0157 100644 (file)
@@ -595,6 +595,10 @@ gboolean collection_add_check(CollectionData *cd, FileData *fd, gboolean sorted,
        struct stat st;
        gboolean valid;
 
+       if (!fd) return FALSE;
+
+       g_assert(fd->magick == FD_MAGICK);
+
        if (must_exist)
                {
                valid = (stat_utf8(fd->path, &st) && !S_ISDIR(st.st_mode));
index e0d70f0..9478cf8 100644 (file)
@@ -1150,8 +1150,10 @@ FileData *file_data_new_group(const gchar *path_utf8)
        filelist_read_real(dir, &files, NULL, TRUE);
 
        fd = g_hash_table_lookup(file_data_pool, path_utf8);
-       g_assert(fd);
-       file_data_ref(fd);
+       if (fd)
+               {
+               file_data_ref(fd);
+               }
 
        filelist_free(files);
        g_free(dir);