Fix non-Latin1 strings in QJsonDocument on big-endian platforms

QJsonDocument stores the entire JSON tree in its binary format. Since
the binary format is the same on-disk as in-memory, it has a fixed
endianness. But when converting from QString to the little-endian
format, the code accidentally converted twice (from little endian, to
little endian), which resulted in a no-op and the string got stored as
big-endian.

It's like encrypting with double-ROT13.

No new testcase because tst_QtJson::removeNonLatinKey was already
failing and gets fixed by this commit.

Task-number: QTBUG-50419
Change-Id: I408dcb81ba654c929f25ffff1428cc79472bbe13
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
bb10
Thiago Macieira 2016-01-12 13:55:01 -08:00
parent 61169b72c2
commit 434302eae1
1 changed files with 1 additions and 1 deletions

View File

@ -305,7 +305,7 @@ public:
{
d->length = str.length();
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
const qle_ushort *uc = (const qle_ushort *)str.unicode();
const ushort *uc = (const ushort *)str.unicode();
for (int i = 0; i < str.length(); ++i)
d->utf16[i] = uc[i];
#else