1
0
Fork 0

Bug 1176, crash loading malformed scenario.

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)
This commit is contained in:
James Turner 2013-10-01 19:57:07 +01:00
parent cc37e31ac9
commit f5b352429c

View file

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