From eb95edf2fcdfaa0d0b2e6203c699f63864377557 Mon Sep 17 00:00:00 2001
From: bcoconni <bcoconni@users.sourceforge.net>
Date: Tue, 14 Jul 2015 16:01:33 +0200
Subject: [PATCH] Prevent JSBSim from crashing when the user forgot to specify
 the axis.

---
 .../models/flight_control/FGSensorOrientation.h     | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/FDM/JSBSim/models/flight_control/FGSensorOrientation.h b/src/FDM/JSBSim/models/flight_control/FGSensorOrientation.h
index f5bdafa89..c56820808 100644
--- a/src/FDM/JSBSim/models/flight_control/FGSensorOrientation.h
+++ b/src/FDM/JSBSim/models/flight_control/FGSensorOrientation.h
@@ -48,7 +48,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_SensorOrientation "$Id: FGSensorOrientation.h,v 1.5 2013/11/17 05:12:57 jberndt Exp $"
+#define ID_SensorOrientation "$Id: FGSensorOrientation.h,v 1.6 2015/07/13 21:50:26 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -65,7 +65,7 @@ CLASS DOCUMENTATION
 Syntax:
 
 @author Jon S. Berndt
-@version $Revision: 1.5 $
+@version $Revision: 1.6 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -80,6 +80,7 @@ public:
     Element* orient_element = element->FindElement("orientation");
     if (orient_element) vOrient = orient_element->FindElementTripletConvertTo("RAD");
 
+    axis = 0;
 
     Element* axis_element = element->FindElement("axis");
     if (axis_element) {
@@ -90,12 +91,14 @@ public:
         axis = 2;
       } else if (sAxis == "Z" || sAxis == "z") {
         axis = 3;
-      } else {
-        std::cerr << "  Incorrect/no axis specified for this sensor; assuming X axis" << std::endl;
-        axis = 1;
       }
     }
 
+    if (!axis) {
+      std::cerr << "  Incorrect/no axis specified for this sensor; assuming X axis" << std::endl;
+      axis = 1;
+    }
+
     CalculateTransformMatrix();
   }