unicode: add utf16decode with utf8 buffer size check

Make use of it in id3tags and cuesheet

Change-Id: I153c23f1f7312e9d5e1de9f03725f2d2ab0abc93
This commit is contained in:
Roman Artiukhin 2024-12-14 12:54:00 +02:00 committed by Solomon Peachy
parent e334a1f95e
commit 1f548f74e6
4 changed files with 34 additions and 42 deletions

View file

@ -265,7 +265,7 @@ bool parse_cuesheet(struct cuesheet_file *cue_file, struct cuesheet *cue)
{
if (char_enc == CHAR_ENC_UTF_16_LE)
{
s = utf16LEdecode(line, utf16_buf, line_len);
s = utf16decode(line, utf16_buf, line_len>>1, sizeof(utf16_buf) - 1, true);
/* terminate the string at the newline */
*s = '\0';
strcpy(line, utf16_buf);
@ -275,7 +275,7 @@ bool parse_cuesheet(struct cuesheet_file *cue_file, struct cuesheet *cue)
}
else if (char_enc == CHAR_ENC_UTF_16_BE)
{
s = utf16BEdecode(line, utf16_buf, line_len);
s = utf16decode(line, utf16_buf, line_len>>1, sizeof(utf16_buf) - 1, false);
*s = '\0';
strcpy(line, utf16_buf);
}