From 11b6ce5218bca998f5a9a6b24fc5ce1beb87412d Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Mon, 26 Nov 2012 09:29:17 +0100 Subject: [PATCH] Fix crash when loading collection listing inexistent files. --- src/collect.c | 4 ++++ src/filedata.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/collect.c b/src/collect.c index c69155dc..e3c01571 100644 --- a/src/collect.c +++ b/src/collect.c @@ -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)); diff --git a/src/filedata.c b/src/filedata.c index e0d70f00..9478cf86 100644 --- a/src/filedata.c +++ b/src/filedata.c @@ -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); -- 2.20.1