From ecd65c69f9c20c5c3d1d0a0f38b332bab84a6b88 Mon Sep 17 00:00:00 2001 From: Pawel Andruszkiewicz Date: Thu, 11 Jun 2015 11:38:17 +0200 Subject: [PATCH] [Messaging] Replaced localtime() with localtime_r(). Prevent CID: 443587 [Verification] Code compiles, pass rate should not change. Change-Id: I16fb79805b9e127b27e2d47f967e354aa2c6b46c Signed-off-by: Pawel Andruszkiewicz --- src/messaging/MsgCommon/Any.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/messaging/MsgCommon/Any.cpp b/src/messaging/MsgCommon/Any.cpp index 0216d2bd..f70392da 100755 --- a/src/messaging/MsgCommon/Any.cpp +++ b/src/messaging/MsgCommon/Any.cpp @@ -162,12 +162,13 @@ std::time_t Any::toTimeT() const { std::time_t current_time; std::time(¤t_time); - std::tm* timeinfo = std::localtime(¤t_time); + struct tm timeinfo = {0}; long int gmtoff = 0; - if (timeinfo) { - gmtoff = timeinfo->tm_gmtoff; + tzset(); + if (nullptr != localtime_r(¤t_time, &timeinfo)) { + gmtoff = timeinfo.tm_gmtoff; - if (timeinfo->tm_isdst) { + if (timeinfo.tm_isdst) { // if dst is set then 1 hour should be subtracted. // 1 hour = 60 second * 60 minutes = 3600 seconds gmtoff -= 3600; -- 2.34.1