From 8ca59441119daf13fbc854dee5fe53a8130cf48d Mon Sep 17 00:00:00 2001 From: shmuels Date: Sun, 18 Apr 2021 10:19:07 +0300 Subject: [PATCH] change localtime to localtime_r which is a thread-safe function --- lib/src/clixon_log.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/clixon_log.c b/lib/src/clixon_log.c index 1d1f1b25..caac71e6 100644 --- a/lib/src/clixon_log.c +++ b/lib/src/clixon_log.c @@ -171,13 +171,13 @@ static int flogtime(FILE *f) { struct timeval tv; - struct tm *tm; + struct tm tm; gettimeofday(&tv, NULL); - tm = localtime((time_t*)&tv.tv_sec); + localtime_r((time_t*)&tv.tv_sec, &tm); fprintf(f, "%s %2d %02d:%02d:%02d: ", - mon2name(tm->tm_mon), tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + mon2name(tm.tm_mon), tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); return 0; }