From 66fcf08bb454d59d213114a94ff07fa705eda9a5 Mon Sep 17 00:00:00 2001
From: Piotr Kosko
Date: Thu, 11 Jun 2015 10:49:15 +0200
Subject: [PATCH] [Content] Fix for prevent issue
[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
---
src/content/content_manager.cc | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/content/content_manager.cc b/src/content/content_manager.cc
index 09453b11..0c8800cb 100755
--- a/src/content/content_manager.cc
+++ b/src/content/content_manager.cc
@@ -55,15 +55,15 @@ const std::map 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;
--
2.34.1