tools/psl.c: Use localtime_r instead of localtime

This commit is contained in:
Tim Rühsen 2022-12-09 13:36:38 +01:00
parent 5eaa8b4796
commit f2bdc1709d
1 changed files with 5 additions and 2 deletions

View File

@ -88,9 +88,12 @@ static void init_windows(void) {
static const char *time2str(time_t t)
{
static char buf[64];
struct tm *tp = localtime(&t);
struct tm tm;
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", tp);
if (localtime_r(&t, &tm) != NULL)
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", &tm);
else
strcpy(buf, "--notime--");
return buf;
}