Fix access to uninitialized values in QtXmlPatterns
authorSami Rosendahl <ext-sami.1.rosendahl@nokia.com>
Tue, 24 Jan 2012 08:43:25 +0000 (10:43 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 1 Feb 2012 12:42:28 +0000 (13:42 +0100)
commitf42f82f435d738339ad85c1380d1167338517247
tree8d1c68a9e32aea78cd54538ea284b92c118e199e
parent2772027a20551d26364c2816e51fcabb20773e74
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>
src/xmlpatterns/api/qabstractxmlnodemodel.cpp
src/xmlpatterns/api/qabstractxmlnodemodel.h
src/xmlpatterns/data/qitem_p.h