]> git.mxchange.org Git - flightgear.git/commitdiff
Fix for bug 1304 - crash loading XML route
authorJames Turner <zakalawe@mac.com>
Fri, 21 Feb 2014 15:51:33 +0000 (07:51 -0800)
committerJames Turner <zakalawe@mac.com>
Fri, 21 Feb 2014 15:57:35 +0000 (07:57 -0800)
If the XML is malformed (missing <route> section), don't crash.

https://code.google.com/p/flightgear-bugs/issues/detail?id=1304

src/Navaids/FlightPlan.cxx

index 23a52f82d86829ba7b16162afd0cb7a4d3648b3e..4e7d7a67d0bed053e297b690613acd05077417b4 100644 (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;
 }