Skip to content

Commit 507145d

Browse files
committed
Fix race when accessing std::locale::classic()
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78552
1 parent 76fec09 commit 507145d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/utiltime.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ void MilliSleep(int64_t n)
7474

7575
std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
7676
{
77+
static std::locale classic(std::locale::classic());
7778
// std::locale takes ownership of the pointer
78-
std::locale loc(std::locale::classic(), new boost::posix_time::time_facet(pszFormat));
79+
std::locale loc(classic, new boost::posix_time::time_facet(pszFormat));
7980
std::stringstream ss;
8081
ss.imbue(loc);
8182
ss << boost::posix_time::from_time_t(nTime);

0 commit comments

Comments
 (0)