Mercurial > geeqie.yaz
changeset 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 | 57f6da2510d9 |
files | ChangeLog src/exif.c src/format_nikon.c src/format_olympus.c |
diffstat | 4 files changed, 26 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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 <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. + Fri Jun 10 20:57:42 2005 John Ellis <johne@verizon.net> * exif.c (exif_parse_IFD_table): Fix offset count before testing
--- 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("");
--- 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");
--- 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); }