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:
Jens Arnold 2007-09-05 06:27:59 +00:00
parent 24006ffeac
commit fcab061250

View file

@ -512,16 +512,19 @@ static int unicode_len(char encoding, const void* string)
int len = 0; int len = 0;
if (encoding == 0x01 || encoding == 0x02) { if (encoding == 0x01 || encoding == 0x02) {
short* s = (short*) string; bool iswchar;
const char *s = string;
while (*s++) { /* string might be unaligned, so using short* can crash on ARM and SH1 */
} do {
iswchar = (*s++ != 0);
len = (void*) s - string; iswchar |= (*s++ != 0);
} while (iswchar);
len = s - (const char*) string;
} else { } else {
len = strlen((char*) string) + 1; len = strlen((char*) string) + 1;
} }
return len; return len;
} }