From a972df05dc643f4c944127596da403d23df7b876 Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Mon, 11 Jan 2016 13:01:05 -0600
Subject: [PATCH] Fix a potential use-after-free in ATC code
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

- when dynamics shuts down the ATC controllers, they clear their
  traffic vectors (destroying the records), but we didn’t notify
  the AI aircraft of this. Ensure the controller is cleared so
  the AI aircraft shutdown doesn’t crash.
---
 src/ATC/trafficcontrol.cxx | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx
index 0da90a6a8..416059529 100644
--- a/src/ATC/trafficcontrol.cxx
+++ b/src/ATC/trafficcontrol.cxx
@@ -190,6 +190,9 @@ FGTrafficRecord::FGTrafficRecord():
 
 FGTrafficRecord::~FGTrafficRecord()
 {
+    if (aircraft) {
+        aircraft->clearATCController();
+    }
 }
 
 void FGTrafficRecord::setPositionAndIntentions(int pos,
-- 
2.39.5