SITL: fixed segv when running examples under SITL

This commit is contained in:
Andrew Tridgell 2018-05-15 07:21:17 +10:00
parent 46b1a2d117
commit 0078a68fbb

View File

@ -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;