1
0
Fork 0

Fix for bug 1304 - crash loading XML route

If the XML is malformed (missing <route> section), don't crash.

https://code.google.com/p/flightgear-bugs/issues/detail?id=1304
This commit is contained in:
James Turner 2014-02-21 07:51:33 -08:00
parent 16869d0362
commit b0dcb657e7

View file

@ -829,11 +829,13 @@ void FlightPlan::loadVersion2XMLRoute(SGPropertyNode_ptr routeData)
// route nodes // route nodes
_legs.clear(); _legs.clear();
SGPropertyNode_ptr routeNode = routeData->getChild("route", 0); SGPropertyNode_ptr routeNode = routeData->getChild("route", 0);
if (routeNode.valid()) {
for (int i=0; i<routeNode->nChildren(); ++i) { for (int i=0; i<routeNode->nChildren(); ++i) {
SGPropertyNode_ptr wpNode = routeNode->getChild("wp", i); SGPropertyNode_ptr wpNode = routeNode->getChild("wp", i);
Leg* l = new Leg(this, Waypt::createFromProperties(NULL, wpNode)); Leg* l = new Leg(this, Waypt::createFromProperties(NULL, wpNode));
_legs.push_back(l); _legs.push_back(l);
} // of route iteration } // of route iteration
}
_waypointsChanged = true; _waypointsChanged = true;
} }