diff --git a/log.cpp b/log.cpp index 60e9d74..46823c6 100644 --- a/log.cpp +++ b/log.cpp @@ -16,8 +16,9 @@ LogEntry::LogEntry(time_t time_, std::string message_) : time(time_), message(st std::string format_log(const LogEntry& entry) { + struct tm tm; char time_as_str[128] = {0}; - strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&entry.time)); + strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&entry.time, &tm)); return std::string(1, '[') + time_as_str + "] " + entry.message; } diff --git a/windows/logs.cpp b/windows/logs.cpp index 524d5bf..e1f0fc9 100644 --- a/windows/logs.cpp +++ b/windows/logs.cpp @@ -22,8 +22,9 @@ static inline void render_table(ImFont* monospace_font, bool* autoscrolling) { size_t i = static_cast(i_u); const LogEntry* log_entry = &log_entries[i]; + struct tm tm; char time_as_str[128] = {0}; - strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&log_entry->time)); + strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&log_entry->time, &tm)); ImGui::TableNextRow(); if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str); diff --git a/windows/main.cpp b/windows/main.cpp index e3f6b79..664707a 100644 --- a/windows/main.cpp +++ b/windows/main.cpp @@ -27,8 +27,9 @@ static inline void render_table(ImFont* monospace_font, std::vector while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { const LogcatEntry* logcat_entry = &logcat_entries[filtered_logcat_entry_offsets[static_cast(i)]]; + struct tm tm; char time_as_str[128] = {0}; - strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time)); + strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&logcat_entry->time, &tm)); ImGui::TableNextRow(); if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str);