aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlirbuilder.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-05-05 13:14:36 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-05-08 04:08:24 +0000
commitc31d6e946d700bb404fdcadaba11ac45c714d60d (patch)
treec007113110b3dce8ea5dffe84ab8f1907c6388ee /src/qml/compiler/qqmlirbuilder.cpp
parentc415e6972b371acc288cd835f5635936215c615f (diff)
Avoid uninitialized bytes in QV4::CompiledData
When populating the QV4::CompiledData for a JS unit, we memset the malloc'ed data to zero. We should do the same when creating a unit for QML files. We do write all the fields that we use, but due to padding we may end up with bytes that are neither used nor written but still uninitialized. Consequently they should be zero'ed, otherwise serialization will write garbage. Change-Id: I0b093e4dde6789d7236247507221f4f3476ba89d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index c645a29b15..63833504f1 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1319,6 +1319,7 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output)
const int totalSize = unitSize + importSize + objectOffsetTableSize + objectsSize + output.jsGenerator.stringTable.sizeOfTableAndData();
char *data = (char*)malloc(totalSize);
memcpy(data, jsUnit, unitSize);
+ memset(data + unitSize, 0, totalSize - unitSize);
if (jsUnit != compilationUnit->data)
free(jsUnit);
jsUnit = 0;