From b915d02f55e0c2b4306719eafe8ffcfb5a587aad Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 4 Feb 2021 16:11:08 +0000 Subject: [PATCH] Fix crash in AI/Traffic code Sentry-Id: FLIGHTGEAR-139 --- src/ATC/trafficcontrol.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 297b7e20a..66f9a0a8e 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -1264,6 +1264,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l if (i == activeTraffic.end() || (activeTraffic.size() == 0)) { SG_LOG(SG_ATC, SG_ALERT, "AI error: updating aircraft without traffic record at " << SG_ORIGIN); + return; } else { i->setPositionAndHeading(lat, lon, heading, speed, alt); current = i; @@ -1273,7 +1274,8 @@ 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()) { + // Sentry FLIGHTGEAR-129: don't crash on null aircraft + if (!i->getAircraft() || !i->getAircraft()->getTrafficRef()) { SG_LOG(SG_ATC, SG_ALERT, "AI traffic: updating aircraft without traffic ref"); return; }