summaryrefslogtreecommitdiff
path: root/src/crashlog.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-13 10:00:41 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-14 23:22:29 +0200
commitaa5a8fe28a224fd581b6053e4a5ce38f3e1a9694 (patch)
tree3641fec62fd2f0969ce0ac06b4f7670d7e43c9f4 /src/crashlog.cpp
parent297d6e20bf0467d2a42e49bee291829ce3bb7c58 (diff)
downloadopenttd-aa5a8fe28a224fd581b6053e4a5ce38f3e1a9694.tar.xz
Codechange: use thread safe time functions
Functions like localtime, gmtime and asctime are not thread safe as they (might) reuse the same buffer. So use the safer _s/_r variant for localtime and gmtime, and use strftime in favour of asctime.
Diffstat (limited to 'src/crashlog.cpp')
-rw-r--r--src/crashlog.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/crashlog.cpp b/src/crashlog.cpp
index c447019fe..c69dddef8 100644
--- a/src/crashlog.cpp
+++ b/src/crashlog.cpp
@@ -32,8 +32,7 @@
#include "game/game_info.hpp"
#include "company_base.h"
#include "company_func.h"
-
-#include <time.h>
+#include "walltime_func.h"
#ifdef WITH_ALLEGRO
# include <allegro.h>
@@ -333,9 +332,8 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const
*/
char *CrashLog::FillCrashLog(char *buffer, const char *last) const
{
- time_t cur_time = time(nullptr);
buffer += seprintf(buffer, last, "*** OpenTTD Crash Report ***\n\n");
- buffer += seprintf(buffer, last, "Crash at: %s", asctime(gmtime(&cur_time)));
+ buffer += UTCTime::Format(buffer, last, "Crash at: %Y-%m-%d %H:%M:%S (UTC)\n");
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);