aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-29 09:39:01 +0200
committerMax Kellermann <max@duempel.org>2008-08-29 09:39:01 +0200
commit9352fc9e6670721f696dda5a15fa1d2419c2e6f8 (patch)
treee008dc6a55cb660560e66ad697d217234ccdd287 /src
parent43c389b961c609f9c705cfe14ed429082ac9115a (diff)
downloadmpd-9352fc9e6670721f696dda5a15fa1d2419c2e6f8.tar.gz
mpd-9352fc9e6670721f696dda5a15fa1d2419c2e6f8.tar.xz
mpd-9352fc9e6670721f696dda5a15fa1d2419c2e6f8.zip
tag: pass length to fix_utf8()
Same as the previous patch, prepare the function fix_utf8() this time.
Diffstat (limited to 'src')
-rw-r--r--src/tag.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tag.c b/src/tag.c
index 1d22b46d1..ff8b1dbd1 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -347,17 +347,18 @@ int tag_equal(struct tag *tag1, struct tag *tag2)
return 1;
}
-static inline char *fix_utf8(char *str) {
+static inline char *fix_utf8(char *str, size_t *length_r) {
char *temp;
assert(str != NULL);
- if (validUtf8String(str, strlen(str)))
+ if (validUtf8String(str, *length_r))
return str;
DEBUG("not valid utf8 in tag: %s\n",str);
temp = latin1StrToUtf8Dup(str);
free(str);
+ *length_r = strlen(temp);
return temp;
}
@@ -370,7 +371,7 @@ static void appendToTagItems(struct tag *tag, enum tag_type type,
memcpy(duplicated, value, len);
duplicated[len] = '\0';
- duplicated = fix_utf8(duplicated);
+ duplicated = fix_utf8(duplicated, &len);
stripReturnChar(duplicated);
tag->numOfItems++;