utils: localtime is not threadsafe, use localtime_r
This commit is contained in:
부모
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)
|
std::string utils::toISODate(time_t t)
|
||||||
{
|
{
|
||||||
struct tm *lt = localtime(&t);
|
struct tm lt;
|
||||||
if(lt == nullptr)
|
if(localtime_r(&t, <) == nullptr)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
char result[20];
|
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)
|
if(x == 0)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
|
불러오는 중...
Reference in New Issue
Block a user