From 09ac87736d1cba2bc599316653a53da297c14171 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 19 Apr 2020 23:18:30 +0200 Subject: [PATCH] utils: localtime is not threadsafe, use localtime_r --- utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils.cpp b/utils.cpp index 2397ded..163d149 100644 --- a/utils.cpp +++ b/utils.cpp @@ -161,13 +161,13 @@ std::string utils::regex_callback_replacer(std::regex regex, const std::string & std::string utils::toISODate(time_t t) { - struct tm *lt = localtime(&t); - if(lt == nullptr) + struct tm lt; + if(localtime_r(&t, <) == nullptr) { return {}; } char result[20]; - size_t x = strftime(result, sizeof(result), "%Y-%m-%d %H:%M:%S", lt); + size_t x = strftime(result, sizeof(result), "%Y-%m-%d %H:%M:%S", <); if(x == 0) { return {};