]> git.mxchange.org Git - flightgear.git/commitdiff
Bug 1176, crash loading malformed scenario.
authorJames Turner <zakalawe@mac.com>
Tue, 1 Oct 2013 18:57:07 +0000 (19:57 +0100)
committerJames Turner <zakalawe@mac.com>
Tue, 1 Oct 2013 18:57:07 +0000 (19:57 +0100)
http://code.google.com/p/flightgear-bugs/issues/detail?id=1176

Don't crash if a scenario specifies a missing or invalid flightplan
(check the flightplan is valid before setting it)

src/AIModel/AIAircraft.cxx

index 101be110be78f3497fb22437a3d695c296280569..eac696d1030e4ccb98f15bf0110025058ff29816 100644 (file)
@@ -235,11 +235,19 @@ double FGAIAircraft::sign(double x) {
 }
 
 
-void FGAIAircraft::setFlightPlan(const std::string& flightplan, bool repeat) {
-    if (!flightplan.empty()) {
-        FGAIFlightPlan* fp = new FGAIFlightPlan(flightplan);
+void FGAIAircraft::setFlightPlan(const std::string& flightplan, bool repeat)
+{
+    if (flightplan.empty()) {
+        SG_LOG(SG_AI, SG_WARN, "setFlightPlan: empty flight plan");
+    }
+    
+    FGAIFlightPlan* fp = new FGAIFlightPlan(flightplan);
+    if (fp->isValidPlan()) {
         fp->setRepeat(repeat);
         SetFlightPlan(fp);
+    } else {
+        SG_LOG(SG_AI, SG_WARN, "setFlightPlan: invalid flightplan specified:" << flightplan);
+        delete fp;
     }
 }