Replaced non-thread-safe localtime with thread-safe equivalent localtime_r
This commit is contained in:
parent
3b16f03674
commit
3ce86d0e4c
1 changed files with 2 additions and 1 deletions
|
@ -21,7 +21,8 @@ static std::string strftime_now(const std::string& format) {
|
|||
time_t rawtime;
|
||||
char buffer[80];
|
||||
time(&rawtime);
|
||||
struct tm* timeinfo = localtime(&rawtime);
|
||||
struct tm timebuf;
|
||||
struct tm* timeinfo = localtime_r(&rawtime, &timebuf);
|
||||
if (!timeinfo || !strftime(buffer, 80, format.c_str(), timeinfo)){return "";}
|
||||
return buffer;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue