From a1768cc6bd5738e5bb9af9527773981b81594a49 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 14 Jan 2015 20:20:11 +0100 Subject: [PATCH] system/helpers.cpp: getNowTimeStr(), use thread save localtime version Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/3538077821620f356762bf44e2caf6842c1a1fce Author: Thilo Graf Date: 2015-01-14 (Wed, 14 Jan 2015) --- src/system/helpers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 20b0496cc..f878eb7b3 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -423,8 +423,9 @@ std::string getNowTimeStr(const char* format) { char tmpStr[256]; struct timeval tv; + struct tm t; gettimeofday(&tv, NULL); - strftime(tmpStr, sizeof(tmpStr), format, localtime(&tv.tv_sec)); + strftime(tmpStr, sizeof(tmpStr), format, localtime_r(&tv.tv_sec, &t)); return (std::string)tmpStr; }