Skip to content

Commit f2bdc17

Browse files
committed
tools/psl.c: Use localtime_r instead of localtime
1 parent 5eaa8b4 commit f2bdc17

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/psl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ static void init_windows(void) {
8888
static const char *time2str(time_t t)
8989
{
9090
static char buf[64];
91-
struct tm *tp = localtime(&t);
91+
struct tm tm;
9292

93-
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", tp);
93+
if (localtime_r(&t, &tm) != NULL)
94+
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", &tm);
95+
else
96+
strcpy(buf, "--notime--");
9497
return buf;
9598
}
9699

0 commit comments

Comments
 (0)