1
0
Fork 0

RouteManager: validate changes to current-wp

Since FlightPlan::setCurrentIndex throws, ensure we validate the value
coming from the property before setting it.

Sentry-Id: FLIGHTGEAR-71
This commit is contained in:
James Turner 2020-10-23 14:48:49 +01:00
parent 4c3aa8b484
commit e0bd74e982

View file

@ -805,6 +805,14 @@ void FGRouteMgr::jumpToIndex(int index)
if (!_plan) {
return;
}
// this method is tied() to current-wp property, but FlightPlan::setCurrentIndex
// will throw on invalid input, so guard against invalid values here.
// See Sentry FLIGHTGEAR-71
if ((index < -1) || (index >= _plan->numLegs())) {
SG_LOG(SG_AUTOPILOT, SG_WARN, "FGRouteMgr::jumpToIndex: ignoring invalid index:" << index);
return;
}
_plan->setCurrentIndex(index);
}