From eb1d8a7dc8d816587248f2e5fe17b8209f8e23a9 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder <build@flightgear.org> Date: Mon, 28 Sep 2020 09:43:21 +0100 Subject: [PATCH] Fix trafific crash that was reported. Probably an edge case of and edge case, but let's guard for it anyway, since it causes traffic to terminate. Sentry-Id: FLIGHTGEAR-2Q --- src/ATC/trafficcontrol.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 75ef7c59b..297b7e20a 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -1272,6 +1272,12 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l int state = i->getState(); + // Sentry FLIGHTGEAR-2Q : don't crash on null TrafficRef + if (!i->getAircraft()->getTrafficRef()) { + SG_LOG(SG_ATC, SG_ALERT, "AI traffic: updating aircraft without traffic ref"); + return; + } + // The user controlled aircraft should have crased here, because it doesn't have a traffic reference. // NOTE: if we create a traffic schedule for the user aircraft, we can use this to plan a flight. time_t startTime = i->getAircraft()->getTrafficRef()->getDepartureTime();