]> git.mxchange.org Git - flightgear.git/commitdiff
Potential fixes for #548, #572, groundnetwork related segfaults
authorThorstenB <brehmt@gmail.com>
Sun, 8 Jan 2012 11:31:18 +0000 (12:31 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 8 Jan 2012 11:31:18 +0000 (12:31 +0100)
Add some pointer checks - so we at least get some error message naming the
airport with the broken network.

src/Airports/groundnetwork.cxx

index bf4d24f7ddaff0df524cd9e3982952e203c180c6..8e9b16fe6fbbd9090ede8eb4a400bb9f46cb9ce8 100644 (file)
@@ -580,9 +580,23 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
     }
 
     FGTaxiNode *firstNode = findNode(start);
+    if (!firstNode)
+    {
+        SG_LOG(SG_GENERAL, SG_ALERT,
+               "Error in ground network. Failed to find first waypoint: " << start
+               << " at " << ((parent) ? parent->getId() : "<unknown>"));
+        return FGTaxiRoute();
+    }
     firstNode->setPathScore(0);
 
     FGTaxiNode *lastNode = findNode(end);
+    if (!lastNode)
+    {
+        SG_LOG(SG_GENERAL, SG_ALERT,
+               "Error in ground network. Failed to find last waypoint: " << end
+               << " at " << ((parent) ? parent->getId() : "<unknown>"));
+        return FGTaxiRoute();
+    }
 
     FGTaxiNodeVector unvisited(*currNodesSet);  // working copy
 
@@ -606,6 +620,13 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
                     seg != best->getEndRoute(); seg++) {
                 if (fullSearch || (*seg)->isPushBack()) {
                     FGTaxiNode *tgt = (*seg)->getEnd();
+                    if (!tgt)
+                    {
+                        SG_LOG(SG_GENERAL, SG_ALERT,
+                               "Error in ground network. Found empty segment "
+                               << " at " << ((parent) ? parent->getId() : "<unknown>"));
+                        return FGTaxiRoute();
+                    }
                     double alt =
                         best->getPathScore() + (*seg)->getLength() +
                         (*seg)->getPenalty(nParkings);