Fix JS_ReadString for wide strings on big endian targets (#354)

swap words of wide character strings upon loading on a big endian target.
This commit is contained in:
Charlie Gordon 2024-04-08 17:02:20 +02:00 committed by GitHub
parent f62b90daa2
commit 56593f419b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33614,7 +33614,13 @@ static JSString *JS_ReadString(BCReaderState *s)
}
memcpy(p->u.str8, s->ptr, size);
s->ptr += size;
if (!is_wide_char) {
if (is_wide_char) {
if (is_be()) {
uint32_t i;
for (i = 0; i < len; i++)
p->u.str16[i] = bswap16(p->u.str16[i]);
}
} else {
p->u.str8[size] = '\0'; /* add the trailing zero for 8 bit strings */
}
#ifdef DUMP_READ_OBJECT