aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compiler.cpp
diff options
context:
space:
mode:
authorRolf Eike Beer <eb@emlix.com>2018-09-07 12:47:06 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-09-14 14:57:37 +0000
commit6ed9a0817a5ab30e8f32aed0ecfa9c6c47071551 (patch)
treee34f8448b76a1e1550629630496202b2048f78f5 /src/qml/compiler/qv4compiler.cpp
parent940c06a4645cca190055a3987db8147b4e2de02c (diff)
properly align string table in compiled data
Change-Id: Ie6534d5443ad046211620c4e0b586d189d0adbef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r--src/qml/compiler/qv4compiler.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index ede0f5cb86..f2e3aaedb5 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -92,13 +92,14 @@ void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit)
{
char *dataStart = reinterpret_cast<char *>(unit);
quint32_le *stringTable = reinterpret_cast<quint32_le *>(dataStart + unit->offsetToStringTable);
- char *stringData = reinterpret_cast<char *>(stringTable) + unit->stringTableSize * sizeof(uint);
+ char *stringData = reinterpret_cast<char *>(stringTable) + WTF::roundUpToMultipleOf(8, unit->stringTableSize * sizeof(uint));
for (int i = backingUnitTableSize ; i < strings.size(); ++i) {
const int index = i - backingUnitTableSize;
stringTable[index] = stringData - dataStart;
const QString &qstr = strings.at(i);
QV4::CompiledData::String *s = reinterpret_cast<QV4::CompiledData::String *>(stringData);
+ Q_ASSERT(reinterpret_cast<uintptr_t>(s) % alignof(QV4::CompiledData::String) == 0);
s->refcount = -1;
s->size = qstr.length();
s->allocAndCapacityReservedFlag = 0;
@@ -664,6 +665,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
if (option == GenerateWithStringTable) {
unit.stringTableSize = stringTable.stringCount();
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
unit.offsetToStringTable = nextOffset;
nextOffset += stringTable.sizeOfTableAndData();
} else {