changeset 644:d062f6b5711a

bar_exif_validate_text(): use computed length and cleanup.
author zas_
date Mon, 12 May 2008 23:00:04 +0000
parents eaf94facc190
children b50deb0f9968
files src/bar_exif.c
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_exif.c	Mon May 12 19:56:28 2008 +0000
+++ b/src/bar_exif.c	Mon May 12 23:00:04 2008 +0000
@@ -143,12 +143,20 @@
 
 gchar *bar_exif_validate_text(gchar *text)
 {
-	if (text && !g_utf8_validate(text, strlen(text), NULL))
+	gint len;
+
+	if (!text) return NULL;
+	
+	len = strlen(text);
+	if (!g_utf8_validate(text, len, NULL))
 		{
-		gchar *tmp = text;
-		text = g_convert(tmp, strlen(tmp), "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
-		g_free(tmp);
+		gchar *conv_text;
+
+		conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+		g_free(text);
+		text = conv_text;
 		}
+
 	return text;
 }