[Content] Fix for prevent issue
authorPiotr Kosko <p.kosko@samsung.com>
Thu, 11 Jun 2015 08:49:15 +0000 (10:49 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Thu, 11 Jun 2015 08:51:10 +0000 (10:51 +0200)
[Feature] Fixed prevent CID: 441793
  localtime replaced with localtime_r

[Verification] Code compiles without errors.
  TCT passrate 100%

Change-Id: Icdd66ed81bc07d9cfe295bbe98cbe10586138ddc
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
src/content/content_manager.cc

index 09453b11f5b7e2fbc7b3b66cebefd888e83ff8e2..0c8800cbcca16fc0d0803755ec7f0aa0239452b0 100755 (executable)
@@ -55,15 +55,15 @@ const std::map<std::string, media_content_orientation_e> orientationMap = {
 static int get_utc_offset() {
   LoggerD("Enter");
   time_t zero = 24 * 60 * 60L;
-  struct tm* timeptr;
+  struct tm time_struct = {0};
   int gmtime_hours = 0;
 
   /* get the local time for Jan 2, 1900 00:00 UTC */
-  timeptr = localtime(&zero);
-  if (nullptr != timeptr) {
-    gmtime_hours = timeptr->tm_hour;
+  tzset();
+  if (nullptr != localtime_r(&zero, &time_struct)) {
+    gmtime_hours = time_struct.tm_hour;
 
-    if (timeptr->tm_mday < 2)
+    if (time_struct.tm_mday < 2)
       gmtime_hours -= 24;
   }
   return gmtime_hours;