diff src/format_olympus.c @ 58:df73b94154e4

Sat Jun 11 01:06:49 2005 John Ellis <johne@verizon.net> * exif.c, format_nikon.c, format_olympus.c: Fix memory leaks, exif_text_list_find_value() will always return newly allocated text.
author gqview
date Sat, 11 Jun 2005 05:11:39 +0000
parents a8c9992320f4
children deafec7cd99f
line wrap: on
line diff
--- a/src/format_olympus.c	Sat Jun 11 01:09:30 2005 +0000
+++ b/src/format_olympus.c	Sat Jun 11 05:11:39 2005 +0000
@@ -211,8 +211,8 @@
 		static ExifMarker marker = { 0x0200, EXIF_FORMAT_STRING, -1,
 					     "Olympus.ShootingMode", "Shooting mode", NULL };
 		guint32 *array = item->data;
-		const gchar *mode;
-		const gchar *pdir = NULL;
+		gchar *mode;
+		gchar *pdir = NULL;
 		gchar *text;
 		gint l;
 
@@ -222,13 +222,16 @@
 			pdir = exif_text_list_find_value(OlympusPanoramaDirection, array[2]);
 			}
 
-		text = g_strdup_printf("%s%s%s, seq %d", (mode) ? mode : "unknown",
+		text = g_strdup_printf("%s%s%s, seq %d", mode,
 				       (pdir) ? " " : "", (pdir) ? pdir : "",
 				       array[1] + 1);
 		l = strlen(text) + 1;
 		item = exif_item_new(marker.format, marker.tag, l, &marker);
 		memcpy(item->data, text, l);
+
 		g_free(text);
+		g_free(pdir);
+		g_free(mode);
 
 		exif->items = g_list_prepend(exif->items, item);
 		}
@@ -239,8 +242,8 @@
 		static ExifMarker marker = { 0x1015, EXIF_FORMAT_STRING, -1,
 					     "Olympus.WhiteBalance", "White balance", NULL };
 		guint16 *array = item->data;
-		const gchar *mode;
-		const gchar *color = NULL;
+		gchar *mode;
+		gchar *color = NULL;
 		gchar *text;
 		gint l;
 
@@ -250,12 +253,15 @@
 			color = exif_text_list_find_value(OlympusWBColorTemp, array[1]);
 			}
 
-		text = g_strdup_printf("%s%s%s", (mode) ? mode : "unknown",
+		text = g_strdup_printf("%s%s%s", mode,
 				       (color) ? " " : "", (color) ? color : "");
 		l = strlen(text) + 1;
 		item = exif_item_new(marker.format, marker.tag, l, &marker);
 		memcpy(item->data, text, l);
+
 		g_free(text);
+		g_free(color);
+		g_free(mode);
 
 		exif->items = g_list_prepend(exif->items, item);
 		}