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:
parent
f62b90daa2
commit
56593f419b
1 changed files with 7 additions and 1 deletions
|
@ -33614,7 +33614,13 @@ static JSString *JS_ReadString(BCReaderState *s)
|
||||||
}
|
}
|
||||||
memcpy(p->u.str8, s->ptr, size);
|
memcpy(p->u.str8, s->ptr, size);
|
||||||
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 */
|
p->u.str8[size] = '\0'; /* add the trailing zero for 8 bit strings */
|
||||||
}
|
}
|
||||||
#ifdef DUMP_READ_OBJECT
|
#ifdef DUMP_READ_OBJECT
|
||||||
|
|
Loading…
Reference in a new issue