utils: localtime is not threadsafe, use localtime_r
这个提交包含在:
父节点
3b2578b7f9
当前提交
09ac87736d
@ -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 {};
|
||||
|
正在加载...
在新工单中引用
屏蔽一个用户