[Messaging] Replaced localtime() with localtime_r().
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 11 Jun 2015 09:38:17 +0000 (11:38 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 11 Jun 2015 09:38:17 +0000 (11:38 +0200)
Prevent CID: 443587

[Verification] Code compiles, pass rate should not change.

Change-Id: I16fb79805b9e127b27e2d47f967e354aa2c6b46c
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/messaging/MsgCommon/Any.cpp

index 0216d2bde3ba22e8b7ea65f21ee7142043f32edf..f70392da7cf903c6c3dc1577be9686e05e9fc2e2 100755 (executable)
@@ -162,12 +162,13 @@ std::time_t Any::toTimeT() const
 {
     std::time_t current_time;
     std::time(&current_time);
-    std::tm* timeinfo = std::localtime(&current_time);
+    struct tm timeinfo = {0};
     long int gmtoff = 0;
-    if (timeinfo) {
-      gmtoff = timeinfo->tm_gmtoff;
+    tzset();
+    if (nullptr != localtime_r(&current_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;