From f0eba69c4a7c2ac82d3e114108f0c1bd84ea3dc5 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 23 Nov 2020 00:20:29 +0100 Subject: [PATCH] Fixed time_t decoding crash on Linux --- source/views/view_data_inspector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/views/view_data_inspector.cpp b/source/views/view_data_inspector.cpp index dc449f85f..8226b5290 100644 --- a/source/views/view_data_inspector.cpp +++ b/source/views/view_data_inspector.cpp @@ -72,7 +72,7 @@ namespace hex { auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time32, this->m_endianess); std::tm * ptm = _localtime32(&endianAdjustedTime); 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); else 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); std::tm * ptm = _localtime64(&endianAdjustedTime); 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); else this->m_cachedData.emplace_back("__time64_t", "Invalid");