Avoid returning null from find{Next,Prev}InOrder(non-null)

The checkNode(p) call relies on p being non-null, so CodeChecker
grumbled. In any case, we should be returning node_impl if we fall off
the end of the structure (which shouldn't be possible, since we
descended into the three and can't come back out on the way up without
passing through node_impl, for which we check). Include a null-check
in checkNode(), save the nsURI.isNull() check when !p->isElement()
makes it redundant and fix some coding style nits while I'm about it.

Amends commit 8609982791928a30a6d836b25810143a064f8c6f

Pick-to: 6.9
Coverity-Id: 474724
Coverity-Id: 474725
Coverity-Id: 474726
Change-Id: Id622a91d2e443276756e50729cf155b10f7164a1
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
This commit is contained in:
Edward Welbourne 2025-02-11 16:42:50 +01:00
parent 97517b20aa
commit 82ae262de2

View File

@ -660,13 +660,13 @@ void QDomNodeListPrivate::createList() const
Checks if a node is valid and fulfills the requirements set during the
generation of this list, i.e. matching tag and matching URI.
*/
bool QDomNodeListPrivate::checkNode(QDomNodePrivate *p) const {
if (nsURI.isNull())
return p->isElement() && p->nodeName() == tagname;
else
return p->isElement() && p->name==tagname && p->namespaceURI==nsURI;
};
*/
bool QDomNodeListPrivate::checkNode(QDomNodePrivate *p) const
{
return p && p->isElement() && (nsURI.isNull()
? p->nodeName() == tagname
: p->name == tagname && p->namespaceURI == nsURI);
}
/*! \internal