From f2bdc1709d662c3d6af56b019def0b9410cd974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 9 Dec 2022 13:36:38 +0100 Subject: [PATCH] tools/psl.c: Use localtime_r instead of localtime --- tools/psl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/psl.c b/tools/psl.c index 5ccfae1..fb20a3d 100644 --- a/tools/psl.c +++ b/tools/psl.c @@ -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; }