Skip to content

Commit

Permalink
tools/psl.c: Use localtime_r instead of localtime
Browse files Browse the repository at this point in the history
  • Loading branch information
rockdaboot committed Dec 9, 2022
1 parent 5eaa8b4 commit f2bdc17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/psl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f2bdc17

Please sign in to comment.