aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-05-07 13:51:26 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-09 17:26:51 +0200
commit0640dce6cd3200979a9b98d5bbae4526fc6dcec8 (patch)
tree15cdc6be016ec728759ca9f0aed88870ed70044e
parent18a96e8f4913dd96bcead3ddde99a015737e3a3b (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 <lars.knoll@digia.com>
-rw-r--r--src/qml/compiler/qv4compileddata_p.h11
-rw-r--r--src/qml/compiler/qv4compiler.cpp6
2 files changed, 6 insertions, 11 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); }
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 65ef5c4b5e..144ef8a79e 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -82,11 +82,7 @@ void QV4::Compiler::StringTableGenerator::serialize(uint *stringTable, char *dat
QV4::CompiledData::String *s = (QV4::CompiledData::String*)(stringData);
s->flags = 0; // ###
- s->str.ref.atomic.store(-1);
- s->str.size = qstr.length();
- s->str.alloc = 0;
- s->str.capacityReserved = false;
- s->str.offset = sizeof(QArrayData);
+ s->size = qstr.length();
memcpy(s + 1, qstr.constData(), (qstr.length() + 1)*sizeof(ushort));
stringData += QV4::CompiledData::String::calculateSize(qstr);