From 8a55b69211b5866025f66c514f34ad697d3d1909 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Thu, 16 Dec 2010 22:26:36 +0100 Subject: [PATCH] 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. --- src/exif-common.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/exif-common.c b/src/exif-common.c index 49b31f23..f87d141d 100644 --- a/src/exif-common.c +++ b/src/exif-common.c @@ -636,14 +636,20 @@ void exif_release_cb(FileData *fd) 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 -- 2.20.1