Skip to content

Commit 56593f4

Browse files
authored
Fix JS_ReadString for wide strings on big endian targets (#354)
swap words of wide character strings upon loading on a big endian target.
1 parent f62b90d commit 56593f4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

quickjs.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33614,7 +33614,13 @@ static JSString *JS_ReadString(BCReaderState *s)
3361433614
}
3361533615
memcpy(p->u.str8, s->ptr, size);
3361633616
s->ptr += size;
33617-
if (!is_wide_char) {
33617+
if (is_wide_char) {
33618+
if (is_be()) {
33619+
uint32_t i;
33620+
for (i = 0; i < len; i++)
33621+
p->u.str16[i] = bswap16(p->u.str16[i]);
33622+
}
33623+
} else {
3361833624
p->u.str8[size] = '\0'; /* add the trailing zero for 8 bit strings */
3361933625
}
3362033626
#ifdef DUMP_READ_OBJECT

0 commit comments

Comments
 (0)