summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-03-10 09:49:22 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-03-10 09:45:34 +0000
commit807240a8831f1b75e945471c129597c4b79a95ea (patch)
tree8d1f1fe464cbd1e9c40b0bf9f489a48de193041a /src/corelib/json
parentf64737527559e22783b57d30ce8bab9ee517974d (diff)
QJsonParser: fix UB (misaligned store) in Parser::parseNumber()
Found by UBSan: qjsonparser.cpp:741:30: runtime error: store to misaligned address 0x0000019b1e94 for type 'quint64', which requires 8 byte alignment Fix by using the qToLittleEndian() overload that can store to misaligned memory. Change-Id: Ib84bd30b13c68f7fdb8870c9fbbfac15cff0112d Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/json')
-rw-r--r--src/corelib/json/qjsonparser.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index 0d62687388..b8a628fdcc 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -732,7 +732,7 @@ bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset)
}
int pos = reserveSpace(sizeof(double));
- *(quint64 *)(data + pos) = qToLittleEndian(ui);
+ qToLittleEndian(ui, reinterpret_cast<uchar *>(data + pos));
if (current - baseOffset >= Value::MaxSize) {
lastError = QJsonParseError::DocumentTooLarge;
return false;