From e38abca385ad4ac6fcb5b0daf486b72d5e19c012 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 7 Jun 2020 19:23:30 +0200 Subject: [PATCH] get_locale_time(): Fix locking of localtime() Previously we were only locking the actual localtime() call while we should keep the lock until the returned pointer is no longer being used. --- cgi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cgi.c b/cgi.c index 580e2bfb..15ef2562 100644 --- a/cgi.c +++ b/cgi.c @@ -1515,13 +1515,15 @@ static void get_locale_time(char *buf, size_t buffer_size) #elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&localtime_mutex); timeptr = localtime(¤t_time); - privoxy_mutex_unlock(&localtime_mutex); #else timeptr = localtime(¤t_time); #endif strftime(buf, buffer_size, "%a %b %d %X %Z %Y", timeptr); +#if !defined(HAVE_LOCALTIME_R) && defined(MUTEX_LOCKS_AVAILABLE) + privoxy_mutex_unlock(&localtime_mutex); +#endif } -- 2.39.2