From: Fabian Keil Date: Sun, 7 Jun 2020 17:23:30 +0000 (+0200) Subject: get_locale_time(): Fix locking of localtime() X-Git-Tag: v_3_0_29~286 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=e38abca385ad4ac6fcb5b0daf486b72d5e19c012 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. --- 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 }