diff options
author | Simon Hausmann <[email protected]> | 2014-05-07 13:51:26 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2014-05-09 17:26:51 +0200 |
commit | 0640dce6cd3200979a9b98d5bbae4526fc6dcec8 (patch) | |
tree | 15cdc6be016ec728759ca9f0aed88870ed70044e /src/qml/compiler/qv4compileddata_p.h | |
parent | 18a96e8f4913dd96bcead3ddde99a015737e3a3b (diff) |
Fix crash on host/target word size mismatches
When compiling on a 64-bit host and using the QV4::CompileData on a 32-bit
target, the size of QArrayData is different. Therefore we cannot use it in
the QV4::CompiledData and have to resort to storing only the characters in
there. We can at least still use fromRawData when extracting strings, but the
QStringData will have to be allocated now.
Change-Id: Ia9dab1722ed72186451b65ba74457051c6ce3155
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 1fba6c0d3c..6ee23690a6 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -151,7 +151,7 @@ struct JSClass struct String { quint32 flags; // isArrayIndex - QArrayData str; + qint32 size; // uint16 strdata[] static int calculateSize(const QString &str) { @@ -195,13 +195,12 @@ struct Unit const uint *offsetTable = reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToStringTable); const uint offset = offsetTable[idx]; const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset); - if (str->str.size == 0) + if (str->size == 0) return QString(); - QStringDataPtr holder = { const_cast<QStringData *>(static_cast<const QStringData*>(&str->str)) }; - QString qstr(holder); + const QChar *characters = reinterpret_cast<const QChar *>(str + 1); if (flags & StaticData) - return qstr; - return QString(qstr.constData(), qstr.length()); + return QString::fromRawData(characters, str->size); + return QString(characters, str->size); } const uint *functionOffsetTable() const { return reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); } |