summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-09-05 06:27:59 +0000
committerJens Arnold <amiconn@rockbox.org>2007-09-05 06:27:59 +0000
commitfcab06125025e86dbad42e49af1c0b5c2a3085fb (patch)
tree3e29c6ec230e4d4196df54d4baad854bf007180b
parent24006ffeacdd6430ec71bad3ae09a27343a4053e (diff)
downloadrockbox-fcab06125025e86dbad42e49af1c0b5c2a3085fb.tar.gz
rockbox-fcab06125025e86dbad42e49af1c0b5c2a3085fb.zip
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
-rw-r--r--firmware/id3.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/firmware/id3.c b/firmware/id3.c
index 8051e461f1..2a894aab10 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -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;
}