changeset 1871:a8cdf1b5af6f

Fix bug 3006812: ensure exif cache is initialized even when all files are unreadable. Add a new function exif_init_cache() and call it at top of exif_read_fd(), the issue was caused by a return NULL on unreadable file, before initializinf exif_cache and when exif_free_fd() is called, file_cache_put() was called on invalid cache.
author Laurent Monin <geeqie@norz.org>
date Thu, 16 Dec 2010 22:26:36 +0100
parents 0edb60ebe74b
children 1160a9de93c2
files src/exif-common.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/exif-common.c	Thu Dec 16 21:55:03 2010 +0100
+++ b/src/exif-common.c	Thu Dec 16 22:26:36 2010 +0100
@@ -636,14 +636,20 @@
 	fd->exif = NULL;
 }
 
+void exif_init_cache(void)
+{
+	assert(!exif_cache);
+	exif_cache = file_cache_new(exif_release_cb, 4);
+}
+
 ExifData *exif_read_fd(FileData *fd)
 {
 	gchar *sidecar_path;
+	
+	if (!exif_cache) exif_init_cache();
 
 	if (!fd || !is_readable_file(fd->path)) return NULL;
 	
-	if (!exif_cache) exif_cache = file_cache_new(exif_release_cb, 4);
-	
 	if (file_cache_get(exif_cache, fd)) return fd->exif;
 	
 	/* CACHE_TYPE_XMP_METADATA file should exist only if the metadata are