From b0dcb657e77579ecc79798ff365737095f96f9e2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 21 Feb 2014 07:51:33 -0800 Subject: [PATCH] Fix for bug 1304 - crash loading XML route If the XML is malformed (missing section), don't crash. https://code.google.com/p/flightgear-bugs/issues/detail?id=1304 --- src/Navaids/FlightPlan.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Navaids/FlightPlan.cxx b/src/Navaids/FlightPlan.cxx index 23a52f82d..4e7d7a67d 100644 --- a/src/Navaids/FlightPlan.cxx +++ b/src/Navaids/FlightPlan.cxx @@ -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; inChildren(); ++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; inChildren(); ++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; } -- 2.39.5