From: ThorstenB Date: Sun, 8 Jan 2012 11:31:18 +0000 (+0100) Subject: Potential fixes for #548, #572, groundnetwork related segfaults X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=277ba10b39deb09ef7a9666325ba67e594986c80;p=flightgear.git 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. --- 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);