Use localtime_r instead of localtime

reverse-scroll
nirenjan 2021-08-03 13:04:46 -07:00
parent e968656672
commit f5331cdef3
1 changed files with 2 additions and 1 deletions

View File

@ -42,6 +42,7 @@ static int get_tz_offset(const char *tz)
char *orig_tz = NULL; char *orig_tz = NULL;
char *orig_tz_copy = NULL; char *orig_tz_copy = NULL;
time_t t; time_t t;
struct tm tmp;
struct tm *timeval; struct tm *timeval;
char *new_tz = NULL; char *new_tz = NULL;
size_t new_tz_len; size_t new_tz_len;
@ -67,7 +68,7 @@ static int get_tz_offset(const char *tz)
setenv("TZ", new_tz, true); setenv("TZ", new_tz, true);
t = time(NULL); t = time(NULL);
timeval = localtime(&t); timeval = localtime_r(&t, &tmp);
if (timeval != NULL) { if (timeval != NULL) {
#if HAVE_STRUCT_TM_TM_GMTOFF #if HAVE_STRUCT_TM_TM_GMTOFF
/* If valid, then timeval.tm_gmtoff contains the offset in seconds east /* If valid, then timeval.tm_gmtoff contains the offset in seconds east