qdoc: Added safety checks to findUnambiguousTarget()
authorMartin Smith <martin.smith@nokia.com>
Thu, 26 Jul 2012 12:16:58 +0000 (14:16 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 30 Jul 2012 08:43:50 +0000 (10:43 +0200)
This is a blind attempt to fix QTBUG-26615. I can't
reproduce the crash on OSX.

Task nr: QTBUG-26615

Change-Id: Ifc6b68b7f302b9cd7d02129be8ae56841a35e5de
Reviewed-by: Martin Smith <martin.smith@nokia.com>
src/tools/qdoc/tree.cpp

index 3123055..4d0e126 100644 (file)
@@ -497,6 +497,9 @@ Tree::findUnambiguousTarget(const QString& target, Atom *&atom, const Node* rela
     int numBestTargets = 0;
     QList<Target> bestTargetList;
 
+    if (priv == 0)
+        return 0;
+
     for (int pass = 0; pass < NumSuffixes; ++pass) {
         TargetHash::const_iterator i = priv->targetHash.constFind(Doc::canonicalTitle(target + suffixes[pass]));
         if (i != priv->targetHash.constEnd()) {
@@ -523,7 +526,7 @@ Tree::findUnambiguousTarget(const QString& target, Atom *&atom, const Node* rela
                 if (relative && !relative->qmlModuleIdentifier().isEmpty()) {
                     for (int i=0; i<bestTargetList.size(); ++i) {
                         const Node* n = bestTargetList.at(i).node;
-                        if (relative->qmlModuleIdentifier() == n->qmlModuleIdentifier()) {
+                        if (n && relative->qmlModuleIdentifier() == n->qmlModuleIdentifier()) {
                             atom = bestTargetList.at(i).atom;
                             return n;
                         }