[Fix] Use localtime_r() instead of localtime() 91/192991/3
authorMilind Murhekar <m.murhekar@samsung.com>
Tue, 13 Nov 2018 11:25:29 +0000 (16:55 +0530)
committerMilind Murhekar <m.murhekar@samsung.com>
Tue, 13 Nov 2018 13:20:12 +0000 (18:50 +0530)
Description: This patch fixes the DF180802-00045
issue.

Change-Id: I78529e672a2f9504168ed98069d8f00b1ededbcc
Signed-off-by: Milind Murhekar <m.murhekar@samsung.com>
src/monitor/stc-time.c

index 81e7a0f..1f30f96 100644 (file)
@@ -36,21 +36,22 @@ time_t stc_time_get_day_start(time_t now)
 
 time_t stc_time_get_week_start(time_t now)
 {
-       struct tm *curr;
+       struct tm curr;
+       struct tm *res;
        int days;
 
-       curr = localtime(&now);
+       res = localtime_r(&now, &curr);
 
-       curr->tm_sec = 0;
-       curr->tm_min = 0;
-       curr->tm_hour = 0;
+       curr.tm_sec = 0;
+       curr.tm_min = 0;
+       curr.tm_hour = 0;
 
-       if (curr->tm_wday > 1)
-               days = curr->tm_wday - 1;
+       if (curr.tm_wday > 1)
+               days = curr.tm_wday - 1;
        else
-               days = 1 - curr->tm_wday;
+               days = 1 - curr.tm_wday;
 
-       return (mktime(curr) - (days * SEC_IN_DAY));
+       return (mktime(&curr) - (days * SEC_IN_DAY));
 }
 
 time_t stc_time_get_month_start(time_t now, int month_start_date)