Hopefully stop the crashes on database init on ARM (and SH1) targets when comment tags using UTF-16 are present.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14618 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
24006ffeac
commit
fcab061250
1 changed files with 10 additions and 7 deletions
|
@ -512,16 +512,19 @@ static int unicode_len(char encoding, const void* string)
|
|||
int len = 0;
|
||||
|
||||
if (encoding == 0x01 || encoding == 0x02) {
|
||||
short* s = (short*) string;
|
||||
|
||||
while (*s++) {
|
||||
}
|
||||
|
||||
len = (void*) s - string;
|
||||
bool iswchar;
|
||||
const char *s = string;
|
||||
/* string might be unaligned, so using short* can crash on ARM and SH1 */
|
||||
do {
|
||||
iswchar = (*s++ != 0);
|
||||
iswchar |= (*s++ != 0);
|
||||
} while (iswchar);
|
||||
|
||||
len = s - (const char*) string;
|
||||
} else {
|
||||
len = strlen((char*) string) + 1;
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue