From 0078a68fbbdcc926d5a9ccc7376393a6488e16fd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 15 May 2018 07:21:17 +1000 Subject: [PATCH] SITL: fixed segv when running examples under SITL --- libraries/SITL/SIM_Aircraft.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index d9e5a79673..70c7ef54a7 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -151,7 +151,8 @@ bool Aircraft::parse_home(const char *home_str, Location &loc, float &yaw_degree float Aircraft::ground_height_difference() const { float h1, h2; - if (sitl->terrain_enable && terrain && + if (sitl && + sitl->terrain_enable && terrain && terrain->height_amsl(home, h1, false) && terrain->height_amsl(location, h2, false)) { return h2 - h1;