summaryrefslogtreecommitdiff
path: root/src/xine-engine/info_helper.c
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2009-04-05 18:39:10 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2009-04-05 18:39:10 +0100
commita6bc7ed17d202107208bbe637ca92d5886c3d686 (patch)
tree2dfb9980680204b9362e6e5cbb66c4ef78d1b167 /src/xine-engine/info_helper.c
parent240889c0d0a7ead9df29c5d154403490fb09e8c7 (diff)
downloadxine-lib-a6bc7ed17d202107208bbe637ca92d5886c3d686.tar.gz
xine-lib-a6bc7ed17d202107208bbe637ca92d5886c3d686.tar.bz2
Fix handling of the length of UTF-16 content sourced from, e.g., ID3 tags.
This avoids use of strlen(), which doesn't cope well with UTF-16, and also has the ID3 parser double-NUL-terminate the buffered string.
Diffstat (limited to 'src/xine-engine/info_helper.c')
-rw-r--r--src/xine-engine/info_helper.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c
index 34d1bbdba..6ce9bcd38 100644
--- a/src/xine-engine/info_helper.c
+++ b/src/xine-engine/info_helper.c
@@ -251,7 +251,15 @@ static void meta_info_set_unlocked_encoding(xine_stream_t *stream, int info, con
size_t inbytesleft, outbytesleft;
inbuf = (ICONV_CONST char *)value;
- inbytesleft = strlen(value);
+ if (!strncmp (enc, "UTF-16", 6) || !strncmp (enc, "UCS-2", 5))
+ {
+ /* strlen() won't work with UTF-16* or UCS-2* */
+ inbytesleft = 0;
+ while (value[inbytesleft] || value[inbytesleft + 1])
+ inbytesleft += 2;
+ } /* ... do we need to handle UCS-4? Probably not. */
+ else
+ inbytesleft = strlen(value);
outbytesleft = 4 * inbytesleft; /* estimative (max) */
outbuf = utf8_value = malloc(outbytesleft+1);