Prevent CID: 443587
[Verification] Code compiles, pass rate should not change.
Change-Id: I16fb79805b9e127b27e2d47f967e354aa2c6b46c
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
{
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;