From 277ba10b39deb09ef7a9666325ba67e594986c80 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 8 Jan 2012 12:31:18 +0100 Subject: [PATCH] Potential fixes for #548, #572, groundnetwork related segfaults Add some pointer checks - so we at least get some error message naming the airport with the broken network. --- src/Airports/groundnetwork.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index bf4d24f7d..8e9b16fe6 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -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() : "")); + 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() : "")); + 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() : "")); + return FGTaxiRoute(); + } double alt = best->getPathScore() + (*seg)->getLength() + (*seg)->getPenalty(nParkings);