diff --git a/libraries/SITL/SIM_GPS_MSP.cpp b/libraries/SITL/SIM_GPS_MSP.cpp index 125f1b8de2..2bf9db476f 100644 --- a/libraries/SITL/SIM_GPS_MSP.cpp +++ b/libraries/SITL/SIM_GPS_MSP.cpp @@ -56,7 +56,8 @@ void GPS_MSP::publish(const GPS_Data *d) auto t = gps_time(); struct timeval tv; simulation_timeval(&tv); - auto *tm = gmtime(&tv.tv_sec); + struct tm tvd {}; + auto *tm = gmtime_r(&tv.tv_sec, &tvd); msp_gps.gps_week = t.week; msp_gps.ms_tow = t.ms; diff --git a/libraries/SITL/SIM_GPS_NMEA.cpp b/libraries/SITL/SIM_GPS_NMEA.cpp index 161f0ef0f0..c4b16b89da 100644 --- a/libraries/SITL/SIM_GPS_NMEA.cpp +++ b/libraries/SITL/SIM_GPS_NMEA.cpp @@ -45,7 +45,8 @@ void GPS_NMEA::publish(const GPS_Data *d) simulation_timeval(&tv); - tm = gmtime(&tv.tv_sec); + struct tm tvd {}; + tm = gmtime_r(&tv.tv_sec, &tvd); // format time string hal.util->snprintf(tstring, sizeof(tstring), "%02u%02u%06.3f", tm->tm_hour, tm->tm_min, tm->tm_sec + tv.tv_usec*1.0e-6);