Core/Misc: Remove unsafe not thread-safe localtime() calls

Replace not thread-safe localtime() calls with thread-safe localtime_r().
This commit is contained in:
jackpoz
2014-10-19 15:09:15 +02:00
parent 035bda05ad
commit 5b08387792
2 changed files with 4 additions and 2 deletions

View File

@@ -2935,7 +2935,8 @@ void World::InitCurrencyResetTime()
// generate time by config
time_t curTime = time(NULL);
tm localTm = *localtime(&curTime);
tm localTm;
localtime_r(&curTime, &localTm);
localTm.tm_wday = getIntConfig(CONFIG_CURRENCY_RESET_DAY);
localTm.tm_hour = getIntConfig(CONFIG_CURRENCY_RESET_HOUR);

View File

@@ -280,7 +280,8 @@ public:
// Format creation date
char createdDateStr[20];
time_t createdDate = guild->GetCreatedDate();
strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", localtime(&createdDate));
tm localTm;
strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", localtime_r(&createdDate, &localTm));
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMemberCount()); // Number of Members