diff --git a/src/quicreach.cpp b/src/quicreach.cpp index 4f0fd99..8183fbd 100644 --- a/src/quicreach.cpp +++ b/src/quicreach.cpp @@ -329,8 +329,13 @@ void DumpResultsToFile() { } char UtcDateTime[256]; time_t Time = time(nullptr); - struct tm* Tm = gmtime(&Time); - strftime(UtcDateTime, sizeof(UtcDateTime), "%Y.%m.%d-%H:%M:%S", Tm); + struct tm Tm; +#ifdef _WIN32 + gmtime_s(&Tm, &Time); +#else + gmtime_r(&Time, &Tm); +#endif + strftime(UtcDateTime, sizeof(UtcDateTime), "%Y.%m.%d-%H:%M:%S", &Tm); fprintf(File, "%s,%u,%u,%u,%u,%u,%u,%u,%u\n", UtcDateTime, Results.TotalCount.load(), Results.ReachableCount.load(), Results.TooMuchCount.load(), Results.MultiRttCount.load(), Results.RetryCount.load(), Results.IPv6Count.load(), Results.Quicv2Count.load(), Results.WayTooMuchCount.load());