--- libgpod-0.7.2/src/itdb_itunesdb.c 2009-12-10 14:39:04.000000000 +0000
+++ libgpod-0.7.2.new/src/itdb_itunesdb.c 2009-12-10 14:56:22.000000000 +0000
@@ -811,6 +811,22 @@ static inline guint64 get64bint (FConten
}
+/* Try to convert from UTF-16 to UTF-8 and handle partial characters
+ * at the end of the string */
+static char *utf16_to_utf8_with_partial (gunichar2 *entry_utf16)
+{
+ GError *error = NULL;
+ char *entry_utf8;
+ glong items_read;
+
+ entry_utf8 = g_utf16_to_utf8 (entry_utf16, -1, &items_read, NULL, &error);
+ if (entry_utf8 == NULL && g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT)) {
+ g_error_free (error);
+ entry_utf8 = g_utf16_to_utf8 (entry_utf16, items_read, NULL, NULL, NULL);
+ }
+
+ return entry_utf8;
+}
/* Fix little endian UTF16 String to correct byteorder if necessary
@@ -1302,7 +1318,7 @@ static char *extract_mhod_string (FConte
entry_utf16 = g_new0 (gunichar2, (len+2)/2);
if (seek_get_n_bytes (cts, (gchar *)entry_utf16, seek+16, len)) {
fixup_little_utf16 (entry_utf16);
- entry_utf8= g_utf16_to_utf8 (entry_utf16, -1, NULL, NULL, NULL);
+ entry_utf8 = utf16_to_utf8_with_partial (entry_utf16);
g_free (entry_utf16);
} else {
g_free (entry_utf16);
@@ -1317,6 +1333,9 @@ static char *extract_mhod_string (FConte
}
}
+ if (entry_utf8 == NULL)
+ return NULL;
+
if (g_utf8_validate (entry_utf8, -1, NULL)) {
return entry_utf8;
} else {