mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-17 07:13:27 +02:00
#3400: fix std::localtime not thread safe
This commit is contained in:
parent
fc0cc6af36
commit
5902bb1277
@ -25,6 +25,8 @@
|
||||
#include <ctime>
|
||||
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
||||
#include "wce_time.h"
|
||||
#elif defined(_WIN32)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -269,7 +271,10 @@ void LocalDateTime::determineTzd(bool adjust)
|
||||
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
||||
std::tm* broken = wceex_localtime(&epochTime);
|
||||
#else
|
||||
std::tm* broken = std::localtime(&epochTime);
|
||||
std::tm brokenBuf;
|
||||
std::tm* broken = &brokenBuf;
|
||||
errno_t err = localtime_s(broken, &epochTime);
|
||||
if (err) broken = nullptr;
|
||||
#endif
|
||||
if (!broken) throw Poco::SystemException("cannot get local time");
|
||||
_tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0));
|
||||
|
Loading…
x
Reference in New Issue
Block a user