summaryrefslogtreecommitdiffstats
path: root/src/xmlpatterns/api
diff options
context:
space:
mode:
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>2012-02-06 08:00:10 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-08 08:20:27 (GMT)
commit9c97217e3bedb2708bba6f23cbc6dd603569e077 (patch)
tree22d9b2a8a5b47671548362786267e68cc12fa445 /src/xmlpatterns/api
parent80cebfde10cf34dcc0777c24f1b3ff37cad20181 (diff)
downloadQt-9c97217e3bedb2708bba6f23cbc6dd603569e077.zip
Qt-9c97217e3bedb2708bba6f23cbc6dd603569e077.tar.gz
Qt-9c97217e3bedb2708bba6f23cbc6dd603569e077.tar.bz2
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 (q 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: I686433ba552f025658f7e583226e77346db82159 (cherry picked from commit f42f82f435d738339ad85c1380d1167338517247) (cherry picked from commit 65d2458408ccda1b37e1069fd13791a60fa0c672) Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/xmlpatterns/api')
-rw-r--r--src/xmlpatterns/api/qabstractxmlnodemodel.cpp11
-rw-r--r--src/xmlpatterns/api/qabstractxmlnodemodel.h11
2 files changed, 10 insertions, 12 deletions
diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
index 81c6473..e0a04f7 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;
}
@@ -1188,10 +1184,7 @@ QXmlItem::QXmlItem(const QVariant &atomicValue)
else
{
m_atomicValue = 0;
- m_node.model = 0;
}
-
- m_node.additionalData = 0;
}
/*!
diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.h b/src/xmlpatterns/api/qabstractxmlnodemodel.h
index f8663ed..8c2f7ec 100644
--- a/src/xmlpatterns/api/qabstractxmlnodemodel.h
+++ b/src/xmlpatterns/api/qabstractxmlnodemodel.h
@@ -105,6 +105,13 @@ namespace QPatternist
/* Implementation is in qabstractxmlnodemodel.cpp. */
inline bool operator!=(const NodeIndexStorage &other) const;
+
+ void reset()
+ {
+ data = 0;
+ additionalData = 0;
+ model = 0;
+ }
};
}
@@ -217,9 +224,7 @@ public:
inline void reset()
{
- m_storage.data = 0;
- m_storage.additionalData = 0;
- m_storage.model = 0;
+ m_storage.reset();
}
private: