]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.cxx
Don't segfault on missing boundary table
[flightgear.git] / src / Environment / environment_ctrl.cxx
index ac870e5e2a377c17d119fe968c7327260ef39f14..0cc434e69392cfe537cf2d616acdff0b50460105 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 #include <algorithm>
+#include <cstring>
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/commands.hxx>
@@ -134,7 +135,9 @@ FGInterpolateEnvironmentCtrl::init ()
        read_table( boundary_n, _boundary_table);
        // pass in a pointer to the environment of the last bondary layer as
        // a starting point
-       read_table( aloft_n, _aloft_table, &(*(_boundary_table.end()-1))->environment);
+       read_table( aloft_n, _aloft_table, 
+               _boundary_table.size() > 0 ?  
+               &(*(_boundary_table.end()-1))->environment : NULL );
 }
 
 void