Skip to content

Commit

Permalink
bar_exif_validate_text(): use computed length and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Monin committed May 12, 2008
1 parent 7b4885c commit 885b212
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/bar_exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,20 @@ enum {

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;
}

Expand Down

0 comments on commit 885b212

Please sign in to comment.