From: Pawel Andruszkiewicz Date: Thu, 11 Jun 2015 09:38:17 +0000 (+0200) Subject: [Messaging] Replaced localtime() with localtime_r(). X-Git-Tag: submit/tizen/20150702.103311^2~2^2~63^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ecd65c69f9c20c5c3d1d0a0f38b332bab84a6b88;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [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 --- 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;