tag: pass length to fix_utf8()
Same as the previous patch, prepare the function fix_utf8() this time.
This commit is contained in:
parent
43c389b961
commit
9352fc9e66
@ -347,17 +347,18 @@ int tag_equal(struct tag *tag1, struct tag *tag2)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *fix_utf8(char *str) {
|
static inline char *fix_utf8(char *str, size_t *length_r) {
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
||||||
if (validUtf8String(str, strlen(str)))
|
if (validUtf8String(str, *length_r))
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
DEBUG("not valid utf8 in tag: %s\n",str);
|
DEBUG("not valid utf8 in tag: %s\n",str);
|
||||||
temp = latin1StrToUtf8Dup(str);
|
temp = latin1StrToUtf8Dup(str);
|
||||||
free(str);
|
free(str);
|
||||||
|
*length_r = strlen(temp);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +371,7 @@ static void appendToTagItems(struct tag *tag, enum tag_type type,
|
|||||||
memcpy(duplicated, value, len);
|
memcpy(duplicated, value, len);
|
||||||
duplicated[len] = '\0';
|
duplicated[len] = '\0';
|
||||||
|
|
||||||
duplicated = fix_utf8(duplicated);
|
duplicated = fix_utf8(duplicated, &len);
|
||||||
stripReturnChar(duplicated);
|
stripReturnChar(duplicated);
|
||||||
|
|
||||||
tag->numOfItems++;
|
tag->numOfItems++;
|
||||||
|
Loading…
Reference in New Issue
Block a user