From 3ce86d0e4cf4b1b525c3d4703cc35532aca67913 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sat, 19 May 2018 21:02:40 +0200 Subject: [PATCH] Replaced non-thread-safe localtime with thread-safe equivalent localtime_r --- lib/stream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stream.cpp b/lib/stream.cpp index af4b512f..3bfaff31 100644 --- a/lib/stream.cpp +++ b/lib/stream.cpp @@ -21,7 +21,8 @@ static std::string strftime_now(const std::string& format) { time_t rawtime; char buffer[80]; time(&rawtime); - struct tm* timeinfo = localtime(&rawtime); + struct tm timebuf; + struct tm* timeinfo = localtime_r(&rawtime, &timebuf); if (!timeinfo || !strftime(buffer, 80, format.c_str(), timeinfo)){return "";} return buffer; }