From f72983e1a6e1b1164a27a3c2a58915039a7d7ea4 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 4 Aug 2021 09:08:02 +0100 Subject: [PATCH] TrafficL Avoid crash on invalid active runway Work-around + log message when the AI flight has an invalid arrival runway. --- src/AIModel/AIFlightPlanCreate.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AIModel/AIFlightPlanCreate.cxx b/src/AIModel/AIFlightPlanCreate.cxx index 04d365d2b..0dcd86e71 100644 --- a/src/AIModel/AIFlightPlanCreate.cxx +++ b/src/AIModel/AIFlightPlanCreate.cxx @@ -989,6 +989,11 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, double decelMetric = decel * SG_KT_TO_MPS; char buffer[12]; + if (!apt->hasRunwayWithIdent(activeRunway)) { + SG_LOG(SG_AI, SG_WARN, "FGAIFlightPlan::createLanding: No such runway " << activeRunway << " at " << apt->ident()); + return false; + } + FGRunway * rwy = apt->getRunwayByIdent(activeRunway); if (!rwy) return false;