Fixed time_t decoding crash on Linux

This commit is contained in:
WerWolv 2020-11-23 00:20:29 +01:00
parent cea366e135
commit f0eba69c4a
1 changed files with 2 additions and 2 deletions

View File

@ -72,7 +72,7 @@ namespace hex {
auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time32, this->m_endianess); auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time32, this->m_endianess);
std::tm * ptm = _localtime32(&endianAdjustedTime); std::tm * ptm = _localtime32(&endianAdjustedTime);
char buffer[32]; char buffer[32];
if (std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm)) if (ptm != nullptr && std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm))
this->m_cachedData.emplace_back("__time32_t", buffer); this->m_cachedData.emplace_back("__time32_t", buffer);
else else
this->m_cachedData.emplace_back("__time32_t", "Invalid"); this->m_cachedData.emplace_back("__time32_t", "Invalid");
@ -82,7 +82,7 @@ namespace hex {
auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time64, this->m_endianess); auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time64, this->m_endianess);
std::tm * ptm = _localtime64(&endianAdjustedTime); std::tm * ptm = _localtime64(&endianAdjustedTime);
char buffer[64]; char buffer[64];
if (std::strftime(buffer, 64, "%a, %d.%m.%Y %H:%M:%S", ptm) != 0) if (ptm != nullptr && std::strftime(buffer, 64, "%a, %d.%m.%Y %H:%M:%S", ptm) != 0)
this->m_cachedData.emplace_back("__time64_t", buffer); this->m_cachedData.emplace_back("__time64_t", buffer);
else else
this->m_cachedData.emplace_back("__time64_t", "Invalid"); this->m_cachedData.emplace_back("__time64_t", "Invalid");