summaryrefslogtreecommitdiff
path: root/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-01-24 10:43:25 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-01 13:42:28 +0100
commitf42f82f435d738339ad85c1380d1167338517247 (patch)
tree8d1c68a9e32aea78cd54538ea284b92c118e199e /src/xmlpatterns/api/qabstractxmlnodemodel.cpp
parent2772027a20551d26364c2816e51fcabb20773e74 (diff)
downloadqtxmlpatterns-f42f82f435d738339ad85c1380d1167338517247.tar.gz
Fix access to uninitialized values in QtXmlPatterns
Fixes valgrind warning like below when executing tst_QXmlQuery::copyConstructor() Conditional jump or move depends on uninitialised value(s) at: QPatternist::NodeIndexStorage::operator!=(QPatternist::NodeIndexStorage const&) const (qabstractxmlnodemodel.cpp:1220) by: QXmlItem::operator=(QXmlItem const&) (qabstractxmlnodemodel.cpp:1228) Reason for the warning is that QPatternist::NodeIndexStorage::operator!= accesses all fields of NodeIndexStorage, which are all not intialized in every execution path of QXmlItem::QXmlItem(const QVariant &) and class QPatternist::Item constructors. Fixed by adding NodeIndexStorage::reset() function that resets all fields and put a call to that function where NodeIndexStorage objects were previously incompletely initialized. Note that unfortunately class NodeIndexStorage cannot have a default constructor, because it is used as a union field. Change-Id: I758df57551ec49ce8c8b357794177b4e6c454d2f Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Dmitry Trofimov Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/xmlpatterns/api/qabstractxmlnodemodel.cpp')
-rw-r--r--src/xmlpatterns/api/qabstractxmlnodemodel.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
index 27240f9..6c299dd 100644
--- a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
+++ b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
@@ -1138,9 +1138,7 @@ bool QAbstractXmlNodeModel::isDeepEqual(const QXmlNodeModelIndex &n1,
*/
QXmlItem::QXmlItem()
{
- m_node.model = 0;
- m_node.data = 0;
- m_node.additionalData = 0;
+ m_node.reset();
}
bool QXmlItem::internalIsAtomicValue() const
@@ -1164,12 +1162,10 @@ QXmlItem::QXmlItem(const QXmlItem &other) : m_node(other.m_node)
*/
QXmlItem::QXmlItem(const QVariant &atomicValue)
{
+ m_node.reset();
if(atomicValue.isNull())
{
/* Then we behave just like the default constructor. */
- m_node.model = 0;
- m_node.data = 0;
- m_node.additionalData = 0;
return;
}
@@ -1185,13 +1181,6 @@ QXmlItem::QXmlItem(const QVariant &atomicValue)
m_node.model = reinterpret_cast<const QAbstractXmlNodeModel *>(~0);
m_atomicValue = temp.asAtomicValue();
}
- else
- {
- m_atomicValue = 0;
- m_node.model = 0;
- }
-
- m_node.additionalData = 0;
}
/*!