From dcc8d22f7c19512941d76d47a7f5fffbbec94fbd Mon Sep 17 00:00:00 2001
From: ThorstenB <brehmt@gmail.com>
Date: Wed, 13 Jul 2011 21:52:29 +0200
Subject: [PATCH] Don't crash on exit, when initialization was aborted. Some
 errors cause fgfs to abort/exit before "controls" is set.

---
 src/Main/globals.cxx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx
index 9ed3a6b56..91af653c0 100644
--- a/src/Main/globals.cxx
+++ b/src/Main/globals.cxx
@@ -182,8 +182,12 @@ FGGlobals::~FGGlobals()
     delete current_panel;
 
     delete ATC_mgr;
-    controls->unbind();
-    delete controls;
+
+    if (controls)
+    {
+        controls->unbind();
+        delete controls;
+    }
 
     delete channel_options_list;
     delete initial_waypoints;