diff src/main.c @ 767:e73d30e0c896

Make utf8_validate_or_convert() to always allocate a new string.
author zas_
date Fri, 30 May 2008 08:36:23 +0000
parents a336b5545af6
children 44128da39e13
line wrap: on
line diff
--- a/src/main.c	Fri May 30 07:20:25 2008 +0000
+++ b/src/main.c	Fri May 30 08:36:23 2008 +0000
@@ -52,7 +52,7 @@
 	return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0);
 }
 
-gchar *utf8_validate_or_convert(gchar *text)
+gchar *utf8_validate_or_convert(const gchar *text)
 {
 	gint len;
 
@@ -60,15 +60,9 @@
 	
 	len = strlen(text);
 	if (!g_utf8_validate(text, len, NULL))
-		{
-		gchar *conv_text;
+		return g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
 
-		conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
-		g_free(text);
-		text = conv_text;
-		}
-
-	return text;
+	return g_strdup(text);
 }
 
 /* Borrowed from gtkfilesystemunix.c */