Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.1
-
None
-
All major platforms supported by Qt.
-
95aa4e4f9b82c3652ffc93310b190db869d491df
Description
Declarative module creates dynamic meta object data in heap, allocating chunk of memory and casting it to appropriate class with reinterpret_cast. Because such chunks never being cleaned (for instance with memset) and class members are aligned - chunk of memory will still contain uninitialized bytes. This leads to potential undefined behavior when comparing such chunks with memcmp in hope that they will be equal. But they will not if class instance has been copied using copy constructor or operator=.
Valgrind triggers several "jump on uninitialized value" errors.
At least if uninitialized memory chunks are ok exactly this cases - they should be cleaned anyway to help to locate real errors.
Example of such comparing:
In qdeclarativecompileddata.cpp:
int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data)
Hot to fix:
In qmetaobjectbuilder.cpp:
Add memset(buf, 0, size).
Here: QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
And here: QMetaObject *QMetaObjectBuilder::toMetaObject() const