# HG changeset patch # User gqview # Date 1118466699 0 # Node ID df73b94154e43dc2a29de69d43b8b31941e7e4b4 # Parent a8c9992320f41d5520dd20faea184ee4c353f035 Sat Jun 11 01:06:49 2005 John Ellis * exif.c, format_nikon.c, format_olympus.c: Fix memory leaks, exif_text_list_find_value() will always return newly allocated text. diff -r a8c9992320f4 -r df73b94154e4 ChangeLog --- a/ChangeLog Sat Jun 11 01:09:30 2005 +0000 +++ b/ChangeLog Sat Jun 11 05:11:39 2005 +0000 @@ -1,3 +1,8 @@ +Sat Jun 11 01:06:49 2005 John Ellis + + * exif.c, format_nikon.c, format_olympus.c: Fix memory leaks, + exif_text_list_find_value() will always return newly allocated text. + Fri Jun 10 20:57:42 2005 John Ellis * exif.c (exif_parse_IFD_table): Fix offset count before testing diff -r a8c9992320f4 -r df73b94154e4 src/exif.c --- a/src/exif.c Sat Jun 11 01:09:30 2005 +0000 +++ b/src/exif.c Sat Jun 11 05:11:39 2005 +0000 @@ -1493,7 +1493,7 @@ if (!exif_get_integer(exif, "Flash", &n)) return NULL; /* Exif 2.1 only defines first 3 bits */ - if (n <= 0x07) return g_strdup(exif_text_list_find_value(ExifFlashList, n)); + if (n <= 0x07) return exif_text_list_find_value(ExifFlashList, n); /* must be Exif 2.2 */ string = g_string_new(""); diff -r a8c9992320f4 -r df73b94154e4 src/format_nikon.c --- a/src/format_nikon.c Sat Jun 11 01:09:30 2005 +0000 +++ b/src/format_nikon.c Sat Jun 11 05:11:39 2005 +0000 @@ -399,19 +399,18 @@ static ExifMarker marker = { 0x0088, EXIF_FORMAT_STRING, -1, "Nikon.AutoFocusPoint", "Auto focus point", NULL }; guchar *array = item->data; - const gchar *text; + gchar *text; + gint l; text = exif_text_list_find_value(NikonAFPoint, (gint)array[1]); - if (text) - { - gint l; + l = strlen(text) + 1; - l = strlen(text) + 1; - item = exif_item_new(marker.format, marker.tag, l, &marker); - memcpy(item->data, text, l); + item = exif_item_new(marker.format, marker.tag, l, &marker); + memcpy(item->data, text, l); - exif->items = g_list_prepend(exif->items, item); - } + g_free(text); + + exif->items = g_list_prepend(exif->items, item); } item = exif_get_item(exif, "Nikon.ISOSpeed"); diff -r a8c9992320f4 -r df73b94154e4 src/format_olympus.c --- 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); }