changeset 865:8d0c91a0f461

do not read keywords and comment between exif_read_fd and exif_free_fd calls (fd->exif does not have reference counting)
author nadvornik
date Fri, 27 Jun 2008 21:35:21 +0000
parents f40509d56fe3
children c879a9a4f186
files src/image-overlay.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/image-overlay.c	Fri Jun 27 21:09:15 2008 +0000
+++ b/src/image-overlay.c	Fri Jun 27 21:35:21 2008 +0000
@@ -214,13 +214,11 @@
 	gchar *name, *data;
 	GString *new;
 	gchar *ret;
-	ExifData *exif;
 
 	if (!str || !*str) return g_strdup("");
 
 	new = g_string_new(str);
 
-	exif = exif_read_fd(imd->image_fd);
 	prev = 0;
 	last = FALSE;
 
@@ -281,10 +279,20 @@
 			}
 		else
 			{
+			/* 
+			   keywords and comment can't be read between exif_read_fd and exif_free_fd calls
+			   because fd->exif does not count references
+			   on the other hand, it is OK to call it in the loop because it is cached
+			*/
+			   
+			ExifData *exif;
+			exif = exif_read_fd(imd->image_fd);
+
 			data = g_strdup(g_hash_table_lookup(vars, name));
 			if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
 			if (!data && exif)
 				data = exif_get_data_as_text(exif, name);
+			exif_free_fd(imd->image_fd, exif);
 			}
 		if (data && *data && limit > 0 && strlen(data) > limit + 3)
 			{
@@ -375,7 +383,6 @@
 		g_free(data);
 		}
 
-	exif_free_fd(imd->image_fd, exif);
 	/* search and destroy empty lines */
 	end = new->str;
 	while ((start = strchr(end, '\n')))