utils: localtime is not threadsafe, use localtime_r

Este commit está contenido en:
Albert S. 2020-04-19 23:18:30 +02:00
padre 3b2578b7f9
commit 09ac87736d
Se han modificado 1 ficheros con 3 adiciones y 3 borrados

Ver fichero

@ -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, &lt) == 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", &lt);
if(x == 0)
{
return {};