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

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