From e0bd74e982ee5718a06f231444c2306a80c30425 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Fri, 23 Oct 2020 14:48:49 +0100 Subject: [PATCH] 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 --- src/Autopilot/route_mgr.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index 762d472b6..c5872a811 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -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); }