summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevon Sargsyan <levon.sargsyan@qt.io>2019-12-05 10:43:37 +0100
committerlevon.sargsyan <levon.sargsyan@qt.io>2019-12-05 15:49:35 +0100
commitba7da547208222ad023f13d4f95ba596689148f0 (patch)
treeab46e087d49c2ee9045abc38adf0968b8e98e84e
parentc8883b59cd2289ef99fa4b912bfa7ff0005242e1 (diff)
downloadqttools-ba7da547208222ad023f13d4f95ba596689148f0.tar.gz
Fix null pointer dereferencing coverity issues in qdoc
This patch fixes potential null pointer derefencing issues all over qdoc project that has been found via coverity scan and has been assigned to "Dereference after null check" category. Fix include coverity issues with REVERSE_NULL as well as FOWARD_NULL cases. Change-Id: Icb6f413ea7bbfae76f8e68139baa31b15575a49a Coverity-Id: 163245 Coverity-Id: 11133 Coverity-Id: 185270 Coverity-Id: 226086 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--src/qdoc/htmlgenerator.cpp4
-rw-r--r--src/qdoc/qdocindexfiles.cpp7
-rw-r--r--src/qdoc/webxmlgenerator.cpp8
3 files changed, 12 insertions, 7 deletions
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 2114d6a8c..5bfa2daeb 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -1909,7 +1909,7 @@ void HtmlGenerator::generateNavigationBar(const QString &title,
const QString &buildversion,
bool tableItems)
{
- if (noNavigationBar)
+ if (noNavigationBar || node == nullptr)
return;
Text navigationbar;
@@ -2879,7 +2879,7 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative,
CodeMarker *marker,
const NodeMultiMap &nmm)
{
- if (nmm.isEmpty())
+ if (nmm.isEmpty() || relative == nullptr)
return;
generateAnnotatedList(relative, marker, nmm.values());
}
diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp
index 9ea7d9f86..9ded66abb 100644
--- a/src/qdoc/qdocindexfiles.cpp
+++ b/src/qdoc/qdocindexfiles.cpp
@@ -157,6 +157,11 @@ void QDocIndexFiles::readIndexFile(const QString &path)
basesList_.clear();
NamespaceNode *root = qdb_->newIndexTree(project_);
+ if (!root) {
+ qWarning() << "Issue parsing index tree" << path;
+ return;
+ }
+
root->tree()->setIndexTitle(indexTitle);
// Scan all elements in the XML file, constructing a map that contains
@@ -387,7 +392,7 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
} else
goto done;
- if (current && current->isExample()) {
+ if (current->isExample()) {
ExampleNode *en = static_cast<ExampleNode *>(current);
if (subtype == QDocAttrFile) {
en->appendFile(name);
diff --git a/src/qdoc/webxmlgenerator.cpp b/src/qdoc/webxmlgenerator.cpp
index 73f6f6268..4b649820f 100644
--- a/src/qdoc/webxmlgenerator.cpp
+++ b/src/qdoc/webxmlgenerator.cpp
@@ -289,6 +289,9 @@ const Atom *WebXMLGenerator::addAtomElements(QXmlStreamWriter &writer,
{
bool keepQuoting = false;
+ if (!atom)
+ return nullptr;
+
switch (atom->type()) {
case Atom::AnnotatedList:
{
@@ -750,11 +753,8 @@ const Atom *WebXMLGenerator::addAtomElements(QXmlStreamWriter &writer,
}
hasQuotingInformation = keepQuoting;
+ return atom->next();
- if (atom)
- return atom->next();
-
- return nullptr;
}
void WebXMLGenerator::startLink(QXmlStreamWriter &writer, const Atom *atom,