From e521ade293af8e89f8a5b66e254589cc93681e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 27 Oct 2018 15:04:15 -0700 Subject: [PATCH] Replace gmtime with safer gmtime_r (#8174) --- src/openrct2/platform/Posix.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 573c5414d5..1724ae1abf 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -48,8 +48,9 @@ void platform_get_date_utc(rct2_date* out_date) assert(out_date != nullptr); time_t rawtime; struct tm* timeinfo; + struct tm buf; time(&rawtime); - timeinfo = gmtime(&rawtime); + timeinfo = gmtime_r(&rawtime, &buf); out_date->day = timeinfo->tm_mday; out_date->month = timeinfo->tm_mon + 1; out_date->year = timeinfo->tm_year + 1900; @@ -61,8 +62,9 @@ void platform_get_time_utc(rct2_time* out_time) assert(out_time != nullptr); time_t rawtime; struct tm* timeinfo; + struct tm buf; time(&rawtime); - timeinfo = gmtime(&rawtime); + timeinfo = gmtime_r(&rawtime, &buf); out_time->second = timeinfo->tm_sec; out_time->minute = timeinfo->tm_min; out_time->hour = timeinfo->tm_hour;